Changed labels to help with export to glb.
This commit is contained in:
parent
4c300dc73b
commit
4fdcc9694d
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
AbstractActionManager,
|
AbstractActionManager,
|
||||||
AbstractMesh,
|
AbstractMesh,
|
||||||
|
InstancedMesh,
|
||||||
Mesh,
|
Mesh,
|
||||||
Observable,
|
Observable,
|
||||||
Observer,
|
Observer,
|
||||||
@ -33,6 +34,7 @@ export class DiagramObject {
|
|||||||
private _sceneObserver: Observer<Scene>;
|
private _sceneObserver: Observer<Scene>;
|
||||||
private _eventObservable: Observable<DiagramEvent>;
|
private _eventObservable: Observable<DiagramEvent>;
|
||||||
private _label: AbstractMesh;
|
private _label: AbstractMesh;
|
||||||
|
private _labelBack: InstancedMesh;
|
||||||
private _meshesPresent: boolean = false;
|
private _meshesPresent: boolean = false;
|
||||||
private _positionHash: string;
|
private _positionHash: string;
|
||||||
private _disposed: boolean = false;
|
private _disposed: boolean = false;
|
||||||
@ -111,6 +113,9 @@ export class DiagramObject {
|
|||||||
if (this._label) {
|
if (this._label) {
|
||||||
this._label.dispose();
|
this._label.dispose();
|
||||||
}
|
}
|
||||||
|
if (this._labelBack) {
|
||||||
|
this._labelBack.dispose();
|
||||||
|
}
|
||||||
if (this._diagramEntity.text != value) {
|
if (this._diagramEntity.text != value) {
|
||||||
this._eventObservable.notifyObservers({
|
this._eventObservable.notifyObservers({
|
||||||
type: DiagramEventType.MODIFY,
|
type: DiagramEventType.MODIFY,
|
||||||
@ -120,6 +125,9 @@ export class DiagramObject {
|
|||||||
this._diagramEntity.text = value;
|
this._diagramEntity.text = value;
|
||||||
this._label = createLabel(value);
|
this._label = createLabel(value);
|
||||||
this._label.parent = this._baseTransform;
|
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();
|
this.updateLabelPosition();
|
||||||
|
|
||||||
|
|
||||||
@ -130,9 +138,15 @@ export class DiagramObject {
|
|||||||
this._mesh.computeWorldMatrix(true);
|
this._mesh.computeWorldMatrix(true);
|
||||||
this._mesh.refreshBoundingInfo();
|
this._mesh.refreshBoundingInfo();
|
||||||
if (this._from && this._to) {
|
if (this._from && this._to) {
|
||||||
this._label.position.x = .06;
|
//this._label.position.x = .06;
|
||||||
this._label.position.z = .06;
|
//this._label.position.z = .06;
|
||||||
this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
|
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 {
|
} else {
|
||||||
const top =
|
const top =
|
||||||
this._mesh.getBoundingInfo().boundingBox.maximumWorld;
|
this._mesh.getBoundingInfo().boundingBox.maximumWorld;
|
||||||
@ -142,7 +156,10 @@ export class DiagramObject {
|
|||||||
const y = temp.position.y;
|
const y = temp.position.y;
|
||||||
temp.dispose();
|
temp.dispose();
|
||||||
this._label.position.y = y + .06;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ function createMaterial(dynamicTexture: DynamicTexture): Material {
|
|||||||
const mat = new StandardMaterial("text-mat", DefaultScene.Scene);
|
const mat = new StandardMaterial("text-mat", DefaultScene.Scene);
|
||||||
//mat.diffuseColor = Color3.Black();
|
//mat.diffuseColor = Color3.Black();
|
||||||
mat.disableLighting = false;
|
mat.disableLighting = false;
|
||||||
mat.backFaceCulling = false;
|
//mat.backFaceCulling = false;
|
||||||
mat.emissiveTexture = dynamicTexture;
|
mat.emissiveTexture = dynamicTexture;
|
||||||
mat.diffuseTexture = dynamicTexture;
|
mat.diffuseTexture = dynamicTexture;
|
||||||
mat.metadata = {exportable: true};
|
mat.metadata = {exportable: true};
|
||||||
|
|||||||
@ -99,15 +99,20 @@ export class Toolbox {
|
|||||||
|
|
||||||
private async buildColorPicker() {
|
private async buildColorPicker() {
|
||||||
let initial = true;
|
let initial = true;
|
||||||
|
const colorArray: Promise<Node>[] = [];
|
||||||
for (const c of colors) {
|
for (const c of colors) {
|
||||||
const cnode = await buildColor(Color3.FromHexString(c), this._scene, this._toolboxBaseNode, this.index++, this._tools);
|
colorArray.push(buildColor(Color3.FromHexString(c), this._scene, this._toolboxBaseNode, this.index++, this._tools));
|
||||||
if (initial) {
|
/*if (initial) {
|
||||||
initial = false;
|
initial = false;
|
||||||
for (const id of cnode.metadata.tools) {
|
for (const id of cnode.metadata.tools) {
|
||||||
this._scene.getNodeById(id)?.setEnabled(true);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user