From 6d2049e1f6d82a88727c25a4bc88638ac0f65efc Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Wed, 12 Nov 2025 21:16:29 -0600 Subject: [PATCH] Convert to unlit rendering and fix connection update error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lighting changes: - Disabled HemisphericLight in customEnvironment - Changed all materials from diffuse to emissive colors - Added disableLighting=true to all StandardMaterials - Updated toolbox colors, diagram entities, and spinner Bug fix: - Fixed "Cannot read properties of undefined (reading 'pickedMesh')" error - Added defensive check in DiagramObject.updateConnection() - Now validates hit array has at least 2 elements before accessing Materials now render at full brightness with unlit/flat shading. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/diagram/diagramObject.ts | 3 +++ src/diagram/functions/buildMeshFromDiagramEntity.ts | 4 +++- src/objects/spinner.ts | 7 +++++-- src/toolbox/functions/buildColor.ts | 5 ++++- src/util/customEnvironment.ts | 9 +++++---- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/diagram/diagramObject.ts b/src/diagram/diagramObject.ts index a3fe403..837bf8f 100644 --- a/src/diagram/diagramObject.ts +++ b/src/diagram/diagramObject.ts @@ -323,6 +323,9 @@ export class DiagramObject { return false; } }); + if (!hit || hit.length < 2) { + return; // No valid intersection found, skip update + } if (hit[0].pickedMesh.id === this._to) { hit.reverse(); } diff --git a/src/diagram/functions/buildMeshFromDiagramEntity.ts b/src/diagram/functions/buildMeshFromDiagramEntity.ts index 228e772..ac8fe86 100644 --- a/src/diagram/functions/buildMeshFromDiagramEntity.ts +++ b/src/diagram/functions/buildMeshFromDiagramEntity.ts @@ -192,7 +192,9 @@ export function buildMissingMaterial(name: string, scene: Scene, color: string): } const newMaterial = new StandardMaterial(name, scene); newMaterial.id = name; - newMaterial.diffuseColor = Color3.FromHexString(color); + newMaterial.emissiveColor = Color3.FromHexString(color); + newMaterial.disableLighting = true; + // newMaterial.diffuseColor = Color3.FromHexString(color); newMaterial.alpha = 1; return newMaterial; } \ No newline at end of file diff --git a/src/objects/spinner.ts b/src/objects/spinner.ts index ab1d62e..2e43347 100644 --- a/src/objects/spinner.ts +++ b/src/objects/spinner.ts @@ -53,8 +53,11 @@ export class Spinner { const text = new DynamicTexture("spinner", {width: 1024, height: 1024}, this._scene, false); text.drawText("Please Wait", 250, 500, "bold 150px Segoe UI", "white", "transparent", true, true); spinner.rotation.z = Math.PI; - material.diffuseTexture = text; - material.diffuseColor.set(.5, .5, 0); + material.emissiveTexture = text; + material.emissiveColor.set(.5, .5, 0); + material.disableLighting = true; + // material.diffuseTexture = text; + // material.diffuseColor.set(.5, .5, 0); const rotate = new Animation("rotate", "rotation.y", 10, Animation.ANIMATIONTYPE_FLOAT, Animation.ANIMATIONLOOPMODE_CYCLE); const keys = []; diff --git a/src/toolbox/functions/buildColor.ts b/src/toolbox/functions/buildColor.ts index addc438..0bffeaf 100644 --- a/src/toolbox/functions/buildColor.ts +++ b/src/toolbox/functions/buildColor.ts @@ -16,8 +16,11 @@ export async function buildColor(color: Color3, scene: Scene, parent: TransformN const width = .1; const height = .1; const material = new StandardMaterial("material-" + color.toHexString(), scene); + material.emissiveColor = color; material.diffuseColor = color; - material.ambientColor = color; + material.disableLighting = true; + // material.diffuseColor = color; + // material.ambientColor = color; //material.roughness = 1; material.specularPower = 64; // material.ambientColor = color; diff --git a/src/util/customEnvironment.ts b/src/util/customEnvironment.ts index bd9b27c..c4c9512 100644 --- a/src/util/customEnvironment.ts +++ b/src/util/customEnvironment.ts @@ -33,10 +33,11 @@ export class CustomEnvironment { this.name = name; this.scene.ambientColor = new Color3(.1, .1, .1); - const light = new HemisphericLight("light1", new Vector3(.5, 1, 1).normalize(), this.scene); - light.groundColor = new Color3(0, 0, 0); - light.diffuse = new Color3(1, 1, 1); - light.intensity = .8; + // Light disabled for unlit rendering + // const light = new HemisphericLight("light1", new Vector3(.5, 1, 1).normalize(), this.scene); + // light.groundColor = new Color3(0, 0, 0); + // light.diffuse = new Color3(1, 1, 1); + // light.intensity = .8; const physics = new CustomPhysics(this.scene); physics .initializeAsync()