Changed labels to help with export to glb.

This commit is contained in:
Michael Mainguy 2024-06-18 09:12:10 -05:00
parent 4c300dc73b
commit 4fdcc9694d
3 changed files with 30 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import {
AbstractActionManager,
AbstractMesh,
InstancedMesh,
Mesh,
Observable,
Observer,
@ -33,6 +34,7 @@ export class DiagramObject {
private _sceneObserver: Observer<Scene>;
private _eventObservable: Observable<DiagramEvent>;
private _label: AbstractMesh;
private _labelBack: InstancedMesh;
private _meshesPresent: boolean = false;
private _positionHash: string;
private _disposed: boolean = false;
@ -111,6 +113,9 @@ export class DiagramObject {
if (this._label) {
this._label.dispose();
}
if (this._labelBack) {
this._labelBack.dispose();
}
if (this._diagramEntity.text != value) {
this._eventObservable.notifyObservers({
type: DiagramEventType.MODIFY,
@ -120,6 +125,9 @@ export class DiagramObject {
this._diagramEntity.text = value;
this._label = createLabel(value);
this._label.parent = this._baseTransform;
this._labelBack = new InstancedMesh('labelBack' + value, (this._label as Mesh));
this._labelBack.parent = this._label;
this._labelBack.metadata = {exportable: true};
this.updateLabelPosition();
@ -130,9 +138,15 @@ export class DiagramObject {
this._mesh.computeWorldMatrix(true);
this._mesh.refreshBoundingInfo();
if (this._from && this._to) {
this._label.position.x = .06;
this._label.position.z = .06;
this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
//this._label.position.x = .06;
//this._label.position.z = .06;
this._label.position.y = .05;
this._label.rotation.y = Math.PI / 2;
this._labelBack.rotation.y = Math.PI;
this._labelBack.position.z = 0.001
//this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
//this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
} else {
const top =
this._mesh.getBoundingInfo().boundingBox.maximumWorld;
@ -142,7 +156,10 @@ export class DiagramObject {
const y = temp.position.y;
temp.dispose();
this._label.position.y = y + .06;
this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
//this._labelBack.position.y = y + .06;
this._labelBack.rotation.y = Math.PI;
this._labelBack.position.z = 0.001
//this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
}
}
}

View File

@ -33,7 +33,7 @@ function createMaterial(dynamicTexture: DynamicTexture): Material {
const mat = new StandardMaterial("text-mat", DefaultScene.Scene);
//mat.diffuseColor = Color3.Black();
mat.disableLighting = false;
mat.backFaceCulling = false;
//mat.backFaceCulling = false;
mat.emissiveTexture = dynamicTexture;
mat.diffuseTexture = dynamicTexture;
mat.metadata = {exportable: true};

View File

@ -99,15 +99,20 @@ export class Toolbox {
private async buildColorPicker() {
let initial = true;
const colorArray: Promise<Node>[] = [];
for (const c of colors) {
const cnode = await buildColor(Color3.FromHexString(c), this._scene, this._toolboxBaseNode, this.index++, this._tools);
if (initial) {
colorArray.push(buildColor(Color3.FromHexString(c), this._scene, this._toolboxBaseNode, this.index++, this._tools));
/*if (initial) {
initial = false;
for (const id of cnode.metadata.tools) {
this._scene.getNodeById(id)?.setEnabled(true);
}
}
}*/
}
const out = await Promise.all(colorArray);
for (const id of out[0].metadata.tools) {
this._scene.getNodeById(id)?.setEnabled(true);
}
}