Fixed up color selector.
This commit is contained in:
parent
95899878c7
commit
be8306141f
@ -51,6 +51,9 @@ export class DiagramManager {
|
||||
if (this.onDiagramEventObservable.hasObservers()) {
|
||||
this.logger.warn("onDiagramEventObservable already has Observers, you should be careful");
|
||||
}
|
||||
this.toolbox.colorChangeObservable.add((evt) => {
|
||||
this.persistenceManager.changeColor(Color3.FromHexString(evt.oldColor), Color3.FromHexString(evt.newColor));
|
||||
}, -1, true, this, false);
|
||||
this.onDiagramEventObservable.add(this.onDiagramEvent, -1, true, this);
|
||||
this.logger.debug("DiagramManager constructed");
|
||||
scene.onMeshRemovedObservable.add((mesh) => {
|
||||
|
||||
@ -174,6 +174,9 @@ export class EditMenu {
|
||||
const template = mesh.metadata.template;
|
||||
const newBase = this.getTool(template,
|
||||
Color3.FromHexString(this.paintColor));
|
||||
if (!newBase) {
|
||||
return;
|
||||
}
|
||||
const newMesh = (mesh as InstancedMesh).clone(mesh.name, mesh.parent, false, newBase);
|
||||
newMesh.id = mesh.id;
|
||||
newMesh.physicsBody = mesh.physicsBody;
|
||||
|
||||
@ -4,6 +4,7 @@ import {
|
||||
InstancedMesh,
|
||||
Mesh,
|
||||
MeshBuilder,
|
||||
Observable,
|
||||
Scene,
|
||||
StandardMaterial,
|
||||
TransformNode,
|
||||
@ -33,6 +34,8 @@ export class Toolbox {
|
||||
private readonly addPanel: StackPanel3D;
|
||||
private readonly controllers: Controllers;
|
||||
private xObserver;
|
||||
public readonly colorChangeObservable: Observable<{ oldColor: string, newColor: string }> =
|
||||
new Observable<{ oldColor: string; newColor: string }>()
|
||||
|
||||
constructor(scene: Scene, controllers: Controllers) {
|
||||
this.scene = scene;
|
||||
@ -212,6 +215,10 @@ export class Toolbox {
|
||||
material.name = "material-" + newColorHex;
|
||||
mesh.id = "toolbox-color-" + newColorHex;
|
||||
mesh.name = "toolbox-color-" + newColorHex;
|
||||
this.colorChangeObservable.notifyObservers({
|
||||
oldColor: oldColor.toHexString(),
|
||||
newColor: newColor.toHexString()
|
||||
});
|
||||
});
|
||||
|
||||
colorPickerTexture.addControl(colorPicker);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user