Updated text labels to be two sided and removed emissive.
This commit is contained in:
parent
717a5c6151
commit
7366b7e856
@ -152,6 +152,7 @@ export class Base {
|
|||||||
transformNode.rotation = newMesh.rotation.clone();
|
transformNode.rotation = newMesh.rotation.clone();
|
||||||
}
|
}
|
||||||
transformNode.setParent(this.controller.motionController.rootMesh);
|
transformNode.setParent(this.controller.motionController.rootMesh);
|
||||||
|
newMesh.setParent(transformNode);
|
||||||
this.grabbedMeshParentId = transformNode.id;
|
this.grabbedMeshParentId = transformNode.id;
|
||||||
this.grabbedMesh = newMesh;
|
this.grabbedMesh = newMesh;
|
||||||
this.previousParentId = null;
|
this.previousParentId = null;
|
||||||
|
|||||||
@ -18,6 +18,7 @@ export function reparent(mesh: AbstractMesh, previousParentId: string, grabbedMe
|
|||||||
if (parent) {
|
if (parent) {
|
||||||
logger.warn('setting parent to null', grabbedMeshParentId, parent)
|
logger.warn('setting parent to null', grabbedMeshParentId, parent)
|
||||||
//this.grabbedMeshParentId = null;
|
//this.grabbedMeshParentId = null;
|
||||||
|
mesh.setParent(null);
|
||||||
parent.dispose();
|
parent.dispose();
|
||||||
} else {
|
} else {
|
||||||
mesh.setParent(null);
|
mesh.setParent(null);
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import {deepCopy} from "../util/functions/deepCopy";
|
|||||||
import {applyPhysics} from "./functions/diagramShapePhysics";
|
import {applyPhysics} from "./functions/diagramShapePhysics";
|
||||||
import {applyScaling} from "./functions/applyScaling";
|
import {applyScaling} from "./functions/applyScaling";
|
||||||
import {toDiagramEntity} from "./functions/toDiagramEntity";
|
import {toDiagramEntity} from "./functions/toDiagramEntity";
|
||||||
|
import {v4 as uuidv4} from 'uuid';
|
||||||
|
|
||||||
|
|
||||||
export class DiagramManager {
|
export class DiagramManager {
|
||||||
@ -70,12 +71,15 @@ export class DiagramManager {
|
|||||||
public createCopy(mesh: AbstractMesh, copy: boolean = false): AbstractMesh {
|
public createCopy(mesh: AbstractMesh, copy: boolean = false): AbstractMesh {
|
||||||
let newMesh;
|
let newMesh;
|
||||||
if (!mesh.isAnInstance) {
|
if (!mesh.isAnInstance) {
|
||||||
newMesh = new InstancedMesh("new", (mesh as Mesh));
|
newMesh = new InstancedMesh('id' + uuidv4(), (mesh as Mesh));
|
||||||
} else {
|
} else {
|
||||||
newMesh = new InstancedMesh("new", (mesh as InstancedMesh).sourceMesh);
|
newMesh = new InstancedMesh('id' + uuidv4(), (mesh as InstancedMesh).sourceMesh);
|
||||||
}
|
}
|
||||||
|
newMesh.id = 'id' + uuidv4();
|
||||||
|
|
||||||
newMesh.actionManager = this.diagramEntityActionManager.manager;
|
newMesh.actionManager = this.diagramEntityActionManager.manager;
|
||||||
newMesh.position = mesh.absolutePosition.clone();
|
newMesh.position = mesh.absolutePosition.clone();
|
||||||
|
|
||||||
if (mesh.absoluteRotationQuaternion) {
|
if (mesh.absoluteRotationQuaternion) {
|
||||||
newMesh.rotation = mesh.absoluteRotationQuaternion.toEulerAngles().clone();
|
newMesh.rotation = mesh.absoluteRotationQuaternion.toEulerAngles().clone();
|
||||||
} else {
|
} else {
|
||||||
@ -88,11 +92,12 @@ export class DiagramManager {
|
|||||||
applyPhysics(this.sounds, newMesh, this.scene);
|
applyPhysics(this.sounds, newMesh, this.scene);
|
||||||
}
|
}
|
||||||
//@TODO Refactor
|
//@TODO Refactor
|
||||||
this.onDiagramEventObservable.notifyObservers({
|
/*this.onDiagramEventObservable.notifyObservers({
|
||||||
type: DiagramEventType.ADD,
|
type: DiagramEventType.ADD,
|
||||||
entity: toDiagramEntity(newMesh)
|
entity: toDiagramEntity(newMesh)
|
||||||
}, 2);
|
}, 2);*/
|
||||||
//this.persistenceManager.add(toDiagramEntity(newMesh));
|
//this.persistenceManager.add(toDiagramEntity(newMesh));
|
||||||
|
|
||||||
return newMesh;
|
return newMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,23 @@
|
|||||||
import {AbstractMesh, Color3, DynamicTexture, Mesh, MeshBuilder, StandardMaterial} from "@babylonjs/core";
|
import {AbstractMesh, DynamicTexture, Material, MeshBuilder, StandardMaterial} from "@babylonjs/core";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
|
|
||||||
export class TextLabel {
|
export class TextLabel {
|
||||||
private static logger: log.Logger = log.getLogger('TextLabel');
|
private static logger: log.Logger = log.getLogger('TextLabel');
|
||||||
|
|
||||||
public static updateTextNode(mesh: AbstractMesh, text: string): AbstractMesh {
|
public static updateTextNode(mesh: AbstractMesh, text: string) {
|
||||||
if (!mesh) {
|
if (!mesh) {
|
||||||
this.logger.error("updateTextNode: mesh is null");
|
this.logger.error("updateTextNode: mesh is null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let textNode = (mesh.getChildren((node) => {
|
const textNodes = mesh.getChildren((node) => {
|
||||||
return node.name == 'text'
|
return node.metadata?.label == true;
|
||||||
})[0] as Mesh);
|
});
|
||||||
if (textNode) {
|
if (textNodes && textNodes.length > 0) {
|
||||||
textNode.dispose(false, true);
|
textNodes.forEach((node) => {
|
||||||
|
node.dispose(false, true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -44,18 +47,30 @@ export class TextLabel {
|
|||||||
}, mesh.getScene(), false);
|
}, mesh.getScene(), false);
|
||||||
const mat = new StandardMaterial("mat", mesh.getScene());
|
const mat = new StandardMaterial("mat", mesh.getScene());
|
||||||
mat.diffuseTexture = dynamicTexture;
|
mat.diffuseTexture = dynamicTexture;
|
||||||
mat.emissiveColor = Color3.White();
|
//mat.emissiveColor = Color3.White();
|
||||||
dynamicTexture.drawText(text, null, null, font, "#000000", "#ffffff", true);
|
dynamicTexture.drawText(text, null, null, font, "#000000", "#ffffff", true);
|
||||||
|
|
||||||
//Create plane and set dynamic texture as material
|
//Create plane and set dynamic texture as material
|
||||||
|
//const plane = MeshBuilder.CreatePlane("text" + text, {width: planeWidth, height: height}, mesh.getScene());
|
||||||
|
|
||||||
|
|
||||||
|
const plane1 = this.createPlane(mat, mesh, text, planeWidth, height);
|
||||||
|
const plane2 = this.createPlane(mat, mesh, text, planeWidth, height);
|
||||||
|
plane2.rotation.y = Math.PI;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static createPlane(mat: Material, mesh: AbstractMesh, text: string, planeWidth: number, height: number): AbstractMesh {
|
||||||
const plane = MeshBuilder.CreatePlane("text" + text, {width: planeWidth, height: height}, mesh.getScene());
|
const plane = MeshBuilder.CreatePlane("text" + text, {width: planeWidth, height: height}, mesh.getScene());
|
||||||
|
|
||||||
plane.material = mat;
|
plane.material = mat;
|
||||||
plane.billboardMode = Mesh.BILLBOARDMODE_ALL;
|
//plane.billboardMode = Mesh.BILLBOARDMODE_ALL;
|
||||||
plane.metadata = {exportable: true};
|
plane.metadata = {exportable: true, label: true};
|
||||||
|
|
||||||
const yOffset = mesh.getBoundingInfo().boundingSphere.radius;
|
const yOffset = mesh.getBoundingInfo().boundingSphere.radius;
|
||||||
plane.parent = mesh;
|
plane.parent = mesh;
|
||||||
plane.position.y = yOffset;
|
plane.position.y = yOffset + height / 2;
|
||||||
plane.scaling.y = 1 / mesh.scaling.y;
|
plane.scaling.y = 1 / mesh.scaling.y;
|
||||||
plane.scaling.x = 1 / mesh.scaling.x;
|
plane.scaling.x = 1 / mesh.scaling.x;
|
||||||
plane.scaling.z = 1 / mesh.scaling.z;
|
plane.scaling.z = 1 / mesh.scaling.z;
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import {MeshBuilder, Scene, Vector3, WebXRDefaultExperience} from "@babylonjs/core";
|
import {AbstractMesh, MeshBuilder, Scene, Vector3, WebXRDefaultExperience} from "@babylonjs/core";
|
||||||
import {AbstractMenu} from "./abstractMenu";
|
import {AbstractMenu} from "./abstractMenu";
|
||||||
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
||||||
import {AdvancedDynamicTexture, Button, Control, ScrollViewer, StackPanel, TextBlock} from "@babylonjs/gui";
|
import {AdvancedDynamicTexture, Button, Control, ScrollViewer, StackPanel, TextBlock} from "@babylonjs/gui";
|
||||||
import {setMenuPosition} from "../util/functions/setMenuPosition";
|
import {setMenuPosition} from "../util/functions/setMenuPosition";
|
||||||
|
|
||||||
export class DiagramListingMenu extends AbstractMenu {
|
export class DiagramListingMenu extends AbstractMenu {
|
||||||
|
private mesh: AbstractMesh;
|
||||||
constructor(scene: Scene, xr: WebXRDefaultExperience, controllers: Controllers) {
|
constructor(scene: Scene, xr: WebXRDefaultExperience, controllers: Controllers) {
|
||||||
super(scene, xr, controllers);
|
super(scene, xr, controllers);
|
||||||
this.buildMenu();
|
this.buildMenu();
|
||||||
@ -17,6 +18,8 @@ export class DiagramListingMenu extends AbstractMenu {
|
|||||||
|
|
||||||
public toggle() {
|
public toggle() {
|
||||||
setMenuPosition(this.handle.mesh, this.scene, new Vector3(0, .4, 0));
|
setMenuPosition(this.handle.mesh, this.scene, new Vector3(0, .4, 0));
|
||||||
|
this.mesh.isVisible = !this.mesh.isVisible;
|
||||||
|
(this.mesh.parent as AbstractMesh).isVisible = this.mesh.isVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildMenu() {
|
private buildMenu() {
|
||||||
@ -26,6 +29,7 @@ export class DiagramListingMenu extends AbstractMenu {
|
|||||||
width: 1,
|
width: 1,
|
||||||
height: .5
|
height: .5
|
||||||
}, this.scene);
|
}, this.scene);
|
||||||
|
this.mesh = configPlane;
|
||||||
const configTexture = AdvancedDynamicTexture.CreateForMesh(configPlane, 2048, 1024);
|
const configTexture = AdvancedDynamicTexture.CreateForMesh(configPlane, 2048, 1024);
|
||||||
|
|
||||||
configTexture.background = "white";
|
configTexture.background = "white";
|
||||||
@ -61,6 +65,7 @@ export class DiagramListingMenu extends AbstractMenu {
|
|||||||
this.createHandle(configPlane);
|
this.createHandle(configPlane);
|
||||||
configPlane.position.y = .5;
|
configPlane.position.y = .5;
|
||||||
setMenuPosition(this.handle.mesh, this.scene, new Vector3(0, .4, 0));
|
setMenuPosition(this.handle.mesh, this.scene, new Vector3(0, .4, 0));
|
||||||
|
this.mesh.isVisible = false;
|
||||||
|
(this.mesh.parent as AbstractMesh).isVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user