From 6631530e2d6e8e52ccec7d3a97b4b6f499095e74 Mon Sep 17 00:00:00 2001 From: Andrea Gargaro Date: Tue, 15 Oct 2024 19:25:36 +0200 Subject: [PATCH] Fix patch color material (#12) * Fix patch material that doesn't use color --- package-lock.json | 4 ++-- package.json | 2 +- src/objects/InstancedMesh2.ts | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb80881..c8e5aa5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@three.ez/instanced-mesh", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@three.ez/instanced-mesh", - "version": "0.2.3", + "version": "0.2.4", "license": "MIT", "dependencies": { "bvh.js": "^0.0.10" diff --git a/package.json b/package.json index 1458658..4f4ae51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@three.ez/instanced-mesh", - "version": "0.2.3", + "version": "0.2.4", "description": "Simplified and enhanced InstancedMesh with frustum culling, fast raycasting (using BVH), sorting, visibility management and more.", "author": "Andrea Gargaro ", "license": "MIT", diff --git a/src/objects/InstancedMesh2.ts b/src/objects/InstancedMesh2.ts index 4b6302a..f0215d7 100644 --- a/src/objects/InstancedMesh2.ts +++ b/src/objects/InstancedMesh2.ts @@ -171,9 +171,12 @@ export class InstancedMesh2< shader.defines["USE_INSTANCING_INDIRECT"] = ""; if (this.colorsTexture !== null) { + if (!shader.fragmentShader.includes("#include ")) return; + shader.uniforms.colorsTexture = { value: this.colorsTexture }; shader.defines["USE_INSTANCING_COLOR_INDIRECT"] = ""; shader.fragmentShader = shader.fragmentShader.replace("#include ", "#define USE_COLOR\n#include "); + // NOTE that '#defined USE_COLOR' is defined only in fragment shader to make it work. } }