mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 15:15:45 +02:00
wip
This commit is contained in:
@@ -146,6 +146,97 @@ type GetOptionsSchemaValues<T extends OptionsSchema> = {
|
||||
never;
|
||||
};
|
||||
|
||||
class ModelManager {
|
||||
public root: BABYLON.Mesh;
|
||||
public updatedCallback: (() => void) | null = null;
|
||||
private bakedMeshes: BABYLON.Mesh[] = [];
|
||||
|
||||
constructor(root: BABYLON.Mesh, updatedCallback: (() => void) | null = null) {
|
||||
this.root = root;
|
||||
this.updatedCallback = updatedCallback;
|
||||
}
|
||||
|
||||
public findMesh(keyword: string) {
|
||||
const mesh = this.root.getChildMeshes().find(m => m.name.includes(keyword));
|
||||
if (mesh == null) {
|
||||
throw new Error(`Mesh with keyword "${keyword}" not found for object ${this.root.metadata?.objectType}`);
|
||||
}
|
||||
return mesh as BABYLON.Mesh;
|
||||
}
|
||||
|
||||
public findMeshes(keyword: string) {
|
||||
const meshes = this.root.getChildMeshes().filter(m => m.name.includes(keyword));
|
||||
return meshes as BABYLON.Mesh[];
|
||||
}
|
||||
|
||||
public findMaterial(keyword: string) {
|
||||
return findMaterial(this.root, keyword);
|
||||
}
|
||||
|
||||
public findTransformNode(keyword: string) {
|
||||
const node = this.root.getChildTransformNodes().find(n => n.name.includes(keyword));
|
||||
if (node == null) {
|
||||
throw new Error(`TransformNode with keyword "${keyword}" not found for object ${this.root.metadata?.objectType}`);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public updated() {
|
||||
this.bakeMesh();
|
||||
this.updatedCallback?.(this.bakedMeshes.length > 0 ? this.bakedMeshes : this.root.getChildMeshes());
|
||||
}
|
||||
|
||||
public bakeMesh() {
|
||||
try {
|
||||
for (const m of this.bakedMeshes) {
|
||||
m.dispose();
|
||||
}
|
||||
this.bakedMeshes = [];
|
||||
|
||||
const childMeshes = this.root.getChildMeshes().filter(m => !m.name.includes('__TOP__') && !m.name.includes('__SIDE__') && !m.name.includes('__COLLISION__'));
|
||||
|
||||
if (childMeshes.length <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const toMerge = [] as BABYLON.Mesh[];
|
||||
for (const mesh of childMeshes) {
|
||||
let fixedMesh = mesh;
|
||||
|
||||
if (mesh instanceof BABYLON.InstancedMesh) {
|
||||
const sourceMesh = mesh.sourceMesh;
|
||||
const newMesh = sourceMesh.clone(mesh.name + '_baked');
|
||||
|
||||
newMesh.position = mesh.position.clone();
|
||||
if (mesh.rotationQuaternion) {
|
||||
newMesh.rotationQuaternion = mesh.rotationQuaternion.clone();
|
||||
} else {
|
||||
newMesh.rotation = mesh.rotation.clone();
|
||||
}
|
||||
newMesh.scaling = mesh.scaling.clone();
|
||||
|
||||
newMesh.parent = mesh.parent;
|
||||
|
||||
mesh.dispose();
|
||||
|
||||
fixedMesh = newMesh;
|
||||
}
|
||||
|
||||
fixedMesh.isVisible = false;
|
||||
toMerge.push(fixedMesh);
|
||||
}
|
||||
|
||||
const merged = BABYLON.Mesh.MergeMeshes(toMerge, false, true, undefined, false, true);
|
||||
|
||||
merged.setParent(this.root);
|
||||
|
||||
this.bakedMeshes = [merged];
|
||||
} catch (err) {
|
||||
console.error('Failed to bake mesh for object', this.root.metadata?.objectType, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type ObjectDef<OpSc extends OptionsSchema = OptionsSchema> = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -162,12 +253,7 @@ type ObjectDef<OpSc extends OptionsSchema = OptionsSchema> = {
|
||||
scene: BABYLON.Scene;
|
||||
root: BABYLON.Mesh;
|
||||
options: Readonly<GetOptionsSchemaValues<OpSc>>;
|
||||
loaderResult: BABYLON.ISceneLoaderAsyncResult;
|
||||
meshUpdated: () => void;
|
||||
findMesh: (keyword: string) => BABYLON.Mesh;
|
||||
findMeshes: (keyword: string) => BABYLON.Mesh[];
|
||||
findMaterial: (keyword: string) => BABYLON.PBRMaterial;
|
||||
findTransformNode: (keyword: string) => BABYLON.TransformNode;
|
||||
model: ModelManager;
|
||||
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>>;
|
||||
};
|
||||
|
||||
@@ -952,40 +1038,22 @@ export class RoomEngine {
|
||||
|
||||
meshUpdated(loaderResult.meshes);
|
||||
|
||||
const model = new ModelManager(subRoot, (meshes) => {
|
||||
meshUpdated(meshes);
|
||||
});
|
||||
|
||||
const objectInstance = def.createInstance({
|
||||
room: this,
|
||||
scene: this.scene,
|
||||
root,
|
||||
options: args.options,
|
||||
loaderResult: loaderResult,
|
||||
meshUpdated: () => {
|
||||
meshUpdated(root.getChildMeshes());
|
||||
},
|
||||
findMesh: (keyword) => {
|
||||
const mesh = root.getChildMeshes().find(m => m.name.includes(keyword));
|
||||
if (mesh == null) {
|
||||
throw new Error(`Mesh with keyword "${keyword}" not found for object ${args.type}`);
|
||||
}
|
||||
return mesh as BABYLON.Mesh;
|
||||
},
|
||||
findMeshes: (keyword) => {
|
||||
const meshes = root.getChildMeshes().filter(m => m.name.includes(keyword));
|
||||
return meshes as BABYLON.Mesh[];
|
||||
},
|
||||
findMaterial: (keyword) => {
|
||||
return findMaterial(root, keyword);
|
||||
},
|
||||
findTransformNode: (keyword) => {
|
||||
const node = root.getChildTransformNodes().find(n => n.name.includes(keyword));
|
||||
if (node == null) {
|
||||
throw new Error(`TransformNode with keyword "${keyword}" not found for object ${args.type}`);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
model,
|
||||
});
|
||||
|
||||
objectInstance.onInited?.();
|
||||
|
||||
model.updated();
|
||||
|
||||
this.objectInstances.set(args.id, objectInstance);
|
||||
this.objectMeshs.set(args.id, root);
|
||||
|
||||
@@ -1558,31 +1626,9 @@ export class RoomObjectPreviewEngine {
|
||||
scene: this.scene,
|
||||
root,
|
||||
options: args.options,
|
||||
loaderResult: loaderResult,
|
||||
meshUpdated: () => {
|
||||
meshUpdated(root.getChildMeshes());
|
||||
},
|
||||
findMesh: (keyword) => {
|
||||
const mesh = root.getChildMeshes().find(m => m.name.includes(keyword));
|
||||
if (mesh == null) {
|
||||
throw new Error(`Mesh with keyword "${keyword}" not found for object ${args.type}`);
|
||||
}
|
||||
return mesh as BABYLON.Mesh;
|
||||
},
|
||||
findMeshes: (keyword) => {
|
||||
const meshes = root.getChildMeshes().filter(m => m.name.includes(keyword));
|
||||
return meshes as BABYLON.Mesh[];
|
||||
},
|
||||
findMaterial: (keyword) => {
|
||||
return findMaterial(root, keyword);
|
||||
},
|
||||
findTransformNode: (keyword) => {
|
||||
const node = root.getChildTransformNodes().find(n => n.name.includes(keyword));
|
||||
if (node == null) {
|
||||
throw new Error(`TransformNode with keyword "${keyword}" not found for object ${args.type}`);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
model: new ModelManager(subRoot, (meshes) => {
|
||||
meshUpdated(meshes);
|
||||
}),
|
||||
});
|
||||
|
||||
objectInstance.onInited?.();
|
||||
|
||||
@@ -21,8 +21,8 @@ export const a4Case = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ options, findMesh }) => {
|
||||
const bodyMesh = findMesh('__X_BODY__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const bodyMesh = model.findMesh('__X_BODY__');
|
||||
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyColor = () => {
|
||||
|
||||
@@ -46,12 +46,12 @@ export const allInOnePc = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ scene, options, findMesh, findMaterial }) => {
|
||||
const screenMesh = findMesh('__X_SCREEN__');
|
||||
createInstance: ({ scene, options, model }) => {
|
||||
const screenMesh = model.findMesh('__X_SCREEN__');
|
||||
|
||||
const bodyMaterial = findMaterial('__X_BODY__');
|
||||
const bezelMaterial = findMaterial('__X_BEZEL__');
|
||||
const screenMaterial = findMaterial('__X_SCREEN__');
|
||||
const bodyMaterial = model.findMaterial('__X_BODY__');
|
||||
const bezelMaterial = model.findMaterial('__X_BEZEL__');
|
||||
const screenMaterial = model.findMaterial('__X_SCREEN__');
|
||||
|
||||
screenMaterial.ambientColor = new BABYLON.Color3(0, 0, 0);
|
||||
screenMaterial.albedoColor = new BABYLON.Color3(0, 0, 0);
|
||||
|
||||
@@ -26,11 +26,11 @@ export const aromaReedDiffuser = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ options, findMesh }) => {
|
||||
const bottleMesh = findMesh('__X_BOTTLE__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const bottleMesh = model.findMesh('__X_BOTTLE__');
|
||||
const bottleMaterial = bottleMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const oilMesh = findMesh('__X_OIL__');
|
||||
const oilMesh = model.findMesh('__X_OIL__');
|
||||
const oilMaterial = oilMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyBottleColor = () => {
|
||||
|
||||
@@ -21,8 +21,8 @@ export const bed = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'floor',
|
||||
createInstance: ({ options, findMesh }) => {
|
||||
const bodyMesh = findMesh('__X_BODY__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const bodyMesh = model.findMesh('__X_BODY__');
|
||||
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyColor = () => {
|
||||
|
||||
@@ -40,13 +40,13 @@ export const blind = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'bottom',
|
||||
createInstance: ({ options, loaderResult, meshUpdated }) => {
|
||||
createInstance: ({ options, model }) => {
|
||||
const temp = createOverridedStates({
|
||||
angle: () => options.angle,
|
||||
open: () => options.open,
|
||||
});
|
||||
|
||||
const blade = loaderResult.meshes[0].getChildMeshes().find(m => m.name === 'Blade') as BABYLON.Mesh;
|
||||
const blade = model.root.getChildMeshes().find(m => m.name === 'Blade') as BABYLON.Mesh;
|
||||
blade.rotation = new BABYLON.Vector3(options.angle, 0, 0);
|
||||
|
||||
let blades = [] as BABYLON.Mesh[];
|
||||
@@ -67,7 +67,7 @@ export const blind = defineObject({
|
||||
blades.push(b);
|
||||
}
|
||||
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
};
|
||||
|
||||
const applyAngle = () => {
|
||||
|
||||
@@ -23,8 +23,8 @@ export const books = defineObject({
|
||||
},
|
||||
placement: 'top',
|
||||
mergeMeshes: ['__X_BOOK_1__', '__X_BOOK_2__', '__X_BOOK_3__', '__X_BOOK_4__', '__X_BOOK_5__', '__X_BOOK_6__', '__X_BOOK_7__', '__X_BOOK_8__', '__X_BOOK_9__', '__X_BOOK_10__'],
|
||||
createInstance: ({ scene, options, findMesh, findMaterial }) => {
|
||||
const coverMaterial = findMaterial('__X_COVER__');
|
||||
createInstance: ({ scene, options, model }) => {
|
||||
const coverMaterial = model.findMaterial('__X_COVER__');
|
||||
|
||||
const applyVariation = () => {
|
||||
const coverTexture =
|
||||
@@ -39,16 +39,16 @@ export const books = defineObject({
|
||||
applyVariation();
|
||||
|
||||
const bookMeshes = [
|
||||
findMesh('__X_BOOK_1__'),
|
||||
findMesh('__X_BOOK_2__'),
|
||||
findMesh('__X_BOOK_3__'),
|
||||
findMesh('__X_BOOK_4__'),
|
||||
findMesh('__X_BOOK_5__'),
|
||||
findMesh('__X_BOOK_6__'),
|
||||
findMesh('__X_BOOK_7__'),
|
||||
findMesh('__X_BOOK_8__'),
|
||||
findMesh('__X_BOOK_9__'),
|
||||
findMesh('__X_BOOK_10__'),
|
||||
model.findMesh('__X_BOOK_1__'),
|
||||
model.findMesh('__X_BOOK_2__'),
|
||||
model.findMesh('__X_BOOK_3__'),
|
||||
model.findMesh('__X_BOOK_4__'),
|
||||
model.findMesh('__X_BOOK_5__'),
|
||||
model.findMesh('__X_BOOK_6__'),
|
||||
model.findMesh('__X_BOOK_7__'),
|
||||
model.findMesh('__X_BOOK_8__'),
|
||||
model.findMesh('__X_BOOK_9__'),
|
||||
model.findMesh('__X_BOOK_10__'),
|
||||
];
|
||||
|
||||
for (const mesh of bookMeshes) {
|
||||
|
||||
@@ -21,8 +21,8 @@ export const cactusS = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ options, findMesh }) => {
|
||||
const potMesh = findMesh('__X_POT__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const potMesh = model.findMesh('__X_POT__');
|
||||
const potMaterial = potMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyPotColor = () => {
|
||||
|
||||
@@ -27,11 +27,11 @@ export const chair = defineObject({
|
||||
},
|
||||
placement: 'floor',
|
||||
isChair: true,
|
||||
createInstance: ({ findMesh, options }) => {
|
||||
const primaryMesh = findMesh('__X_PRIMARY__');
|
||||
createInstance: ({ model, options }) => {
|
||||
const primaryMesh = model.findMesh('__X_PRIMARY__');
|
||||
const primaryMaterial = primaryMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const secondaryMesh = findMesh('__X_SECONDARY__');
|
||||
const secondaryMesh = model.findMesh('__X_SECONDARY__');
|
||||
const secondaryMaterial = secondaryMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyPrimaryColor = () => {
|
||||
|
||||
@@ -21,8 +21,8 @@ export const colorBox = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'floor',
|
||||
createInstance: ({ options, findMesh }) => {
|
||||
const bodyMesh = findMesh('__X_BODY__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const bodyMesh = model.findMesh('__X_BODY__');
|
||||
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyColor = () => {
|
||||
|
||||
@@ -21,8 +21,8 @@ export const desk = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'floor',
|
||||
createInstance: ({ options, findMaterial }) => {
|
||||
const topMaterial = findMaterial('__X_BODY__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const topMaterial = model.findMaterial('__X_BODY__');
|
||||
|
||||
const applyTopColor = () => {
|
||||
const [r, g, b] = options.topColor;
|
||||
|
||||
@@ -54,13 +54,13 @@ export const laptopPc = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ scene, options, findMesh, findMaterial, findTransformNode }) => {
|
||||
const screenMesh = findMesh('__X_SCREEN__');
|
||||
const hutaNode = findTransformNode('__X_HUTA__');
|
||||
createInstance: ({ scene, options, model }) => {
|
||||
const screenMesh = model.findMesh('__X_SCREEN__');
|
||||
const hutaNode = model.findTransformNode('__X_HUTA__');
|
||||
|
||||
const bodyMaterial = findMaterial('__X_BODY__');
|
||||
const bezelMaterial = findMaterial('__X_BEZEL__');
|
||||
const screenMaterial = findMaterial('__X_SCREEN__');
|
||||
const bodyMaterial = model.findMaterial('__X_BODY__');
|
||||
const bezelMaterial = model.findMaterial('__X_BEZEL__');
|
||||
const screenMaterial = model.findMaterial('__X_SCREEN__');
|
||||
|
||||
screenMaterial.ambientColor = new BABYLON.Color3(0, 0, 0);
|
||||
screenMaterial.albedoColor = new BABYLON.Color3(0, 0, 0);
|
||||
|
||||
@@ -21,8 +21,8 @@ export const monitorSpeaker = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ options, findMesh }) => {
|
||||
const bodyMesh = findMesh('__X_BODY__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const bodyMesh = model.findMesh('__X_BODY__');
|
||||
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyColor = () => {
|
||||
|
||||
@@ -26,9 +26,9 @@ export const petBottle = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ findMesh, options }) => {
|
||||
const capMesh = findMesh('__X_CAP__');
|
||||
const liquidMesh = findMesh('__X_LIQUID__');
|
||||
createInstance: ({ model, options }) => {
|
||||
const capMesh = model.findMesh('__X_CAP__');
|
||||
const liquidMesh = model.findMesh('__X_LIQUID__');
|
||||
|
||||
const applyWithCap = () => {
|
||||
capMesh.setEnabled(options.withCap);
|
||||
|
||||
@@ -83,17 +83,17 @@ export const pictureFrame = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'side',
|
||||
createInstance: ({ scene, options, findMaterial, findMesh, meshUpdated }) => {
|
||||
const frameMesh = findMesh('__X_FRAME__');
|
||||
createInstance: ({ scene, options, model }) => {
|
||||
const frameMesh = model.findMesh('__X_FRAME__');
|
||||
frameMesh.rotationQuaternion = null;
|
||||
const matMesh = findMesh('__X_MAT__');
|
||||
const matMesh = model.findMesh('__X_MAT__');
|
||||
matMesh.rotationQuaternion = null;
|
||||
const coverMesh = findMesh('__X_COVER__');
|
||||
const coverMesh = model.findMesh('__X_COVER__');
|
||||
coverMesh.rotationQuaternion = null;
|
||||
const pictureMesh = findMesh('__X_PICTURE__');
|
||||
const pictureMesh = model.findMesh('__X_PICTURE__');
|
||||
pictureMesh.rotationQuaternion = null;
|
||||
|
||||
const pictureMaterial = findMaterial('__X_PICTURE__');
|
||||
const pictureMaterial = model.findMaterial('__X_PICTURE__');
|
||||
|
||||
const updateUv = createPlaneUvMapper(pictureMesh);
|
||||
|
||||
@@ -115,7 +115,7 @@ export const pictureFrame = defineObject({
|
||||
|
||||
const applyFrameThickness = () => {
|
||||
frameMesh.morphTargetManager!.getTargetByName('Thickness')!.influence = options.frameThickness;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applyFrameThickness();
|
||||
@@ -126,7 +126,7 @@ export const pictureFrame = defineObject({
|
||||
pictureMesh.morphTargetManager!.getTargetByName('Width')!.influence = options.width * (1 - options.matHThickness);
|
||||
pictureMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height * (1 - options.matVThickness);
|
||||
matMesh.isVisible = options.matHThickness > 0 || options.matVThickness > 0;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
|
||||
applyFit();
|
||||
};
|
||||
@@ -140,7 +140,7 @@ export const pictureFrame = defineObject({
|
||||
matMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
|
||||
coverMesh.morphTargetManager!.getTargetByName('Width')!.influence = options.width;
|
||||
coverMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
|
||||
applyMatThickness();
|
||||
};
|
||||
@@ -151,7 +151,7 @@ export const pictureFrame = defineObject({
|
||||
frameMesh.morphTargetManager!.getTargetByName('Depth')!.influence = options.depth;
|
||||
//coverMesh.morphTargetManager!.getTargetByName('Depth')!.influence = options.depth;
|
||||
coverMesh.morphTargetManager!.getTargetByName('Depth')!.influence = 0;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applyDepth();
|
||||
@@ -178,7 +178,7 @@ export const pictureFrame = defineObject({
|
||||
|
||||
applyCustomPicture();
|
||||
|
||||
const frameMaterial = findMaterial('__X_FRAME__');
|
||||
const frameMaterial = model.findMaterial('__X_FRAME__');
|
||||
|
||||
const applyFrameColor = () => {
|
||||
const [r, g, b] = options.frameColor;
|
||||
|
||||
@@ -44,13 +44,13 @@ export const poster = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'side',
|
||||
createInstance: ({ scene, options, findMaterial, findMesh, findMeshes, meshUpdated }) => {
|
||||
const pictureMesh = findMesh('__X_PICTURE__');
|
||||
createInstance: ({ scene, options, model }) => {
|
||||
const pictureMesh = model.findMesh('__X_PICTURE__');
|
||||
pictureMesh.rotationQuaternion = null;
|
||||
|
||||
const pictureMaterial = findMaterial('__X_PICTURE__');
|
||||
const pictureMaterial = model.findMaterial('__X_PICTURE__');
|
||||
|
||||
const pinMeshes = findMeshes('__X_PIN__');
|
||||
const pinMeshes = model.findMeshes('__X_PIN__');
|
||||
|
||||
const updateUv = createPlaneUvMapper(pictureMesh);
|
||||
|
||||
@@ -77,7 +77,7 @@ export const poster = defineObject({
|
||||
pinMesh.morphTargetManager!.getTargetByName('Width')!.influence = options.width;
|
||||
pinMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
|
||||
}
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
|
||||
applyFit();
|
||||
};
|
||||
|
||||
@@ -26,11 +26,11 @@ export const speaker = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ options, findMesh }) => {
|
||||
const outerMesh = findMesh('__X_COVER__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const outerMesh = model.findMesh('__X_COVER__');
|
||||
const outerMaterial = outerMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const innerMesh = findMesh('__X_BODY__');
|
||||
const innerMesh = model.findMesh('__X_BODY__');
|
||||
const innerMaterial = innerMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
const applyOuterColor = () => {
|
||||
|
||||
@@ -83,17 +83,17 @@ export const tabletopPictureFrame = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ scene, options, findMaterial, findMesh, meshUpdated }) => {
|
||||
const frameMesh = findMesh('__X_FRAME__');
|
||||
createInstance: ({ scene, options, model }) => {
|
||||
const frameMesh = model.findMesh('__X_FRAME__');
|
||||
frameMesh.rotationQuaternion = null;
|
||||
const matMesh = findMesh('__X_MAT__');
|
||||
const matMesh = model.findMesh('__X_MAT__');
|
||||
matMesh.rotationQuaternion = null;
|
||||
const coverMesh = findMesh('__X_COVER__');
|
||||
const coverMesh = model.findMesh('__X_COVER__');
|
||||
coverMesh.rotationQuaternion = null;
|
||||
const pictureMesh = findMesh('__X_PICTURE__');
|
||||
const pictureMesh = model.findMesh('__X_PICTURE__');
|
||||
pictureMesh.rotationQuaternion = null;
|
||||
|
||||
const pictureMaterial = findMaterial('__X_PICTURE__');
|
||||
const pictureMaterial = model.findMaterial('__X_PICTURE__');
|
||||
|
||||
const updateUv = createPlaneUvMapper(pictureMesh);
|
||||
|
||||
@@ -118,7 +118,7 @@ export const tabletopPictureFrame = defineObject({
|
||||
coverMesh.morphTargetManager!.getTargetByName('FrameThickness')!.influence = options.frameThickness;
|
||||
matMesh.morphTargetManager!.getTargetByName('FrameThickness')!.influence = options.frameThickness;
|
||||
pictureMesh.morphTargetManager!.getTargetByName('FrameThickness')!.influence = options.frameThickness;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applyFrameThickness();
|
||||
@@ -131,7 +131,7 @@ export const tabletopPictureFrame = defineObject({
|
||||
pictureMesh.morphTargetManager!.getTargetByName('MatH')!.influence = options.matHThickness * options.width;
|
||||
pictureMesh.morphTargetManager!.getTargetByName('MatV')!.influence = options.matVThickness * options.height;
|
||||
matMesh.isVisible = options.matHThickness > 0 || options.matVThickness > 0;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
|
||||
applyFit();
|
||||
};
|
||||
@@ -145,7 +145,7 @@ export const tabletopPictureFrame = defineObject({
|
||||
matMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
|
||||
coverMesh.morphTargetManager!.getTargetByName('Width')!.influence = options.width;
|
||||
coverMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
|
||||
applyMatThickness();
|
||||
};
|
||||
@@ -156,7 +156,7 @@ export const tabletopPictureFrame = defineObject({
|
||||
frameMesh.morphTargetManager!.getTargetByName('Depth')!.influence = options.depth;
|
||||
//coverMesh.morphTargetManager!.getTargetByName('Depth')!.influence = options.depth;
|
||||
coverMesh.morphTargetManager!.getTargetByName('Depth')!.influence = 0;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applyDepth();
|
||||
@@ -183,7 +183,7 @@ export const tabletopPictureFrame = defineObject({
|
||||
|
||||
applyCustomPicture();
|
||||
|
||||
const frameMaterial = findMaterial('__X_FRAME__');
|
||||
const frameMaterial = model.findMaterial('__X_FRAME__');
|
||||
|
||||
const applyFrameColor = () => {
|
||||
const [r, g, b] = options.frameColor;
|
||||
|
||||
@@ -44,15 +44,15 @@ export const tapestry = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'side',
|
||||
createInstance: ({ scene, options, findMaterial, findMesh, findMeshes, meshUpdated }) => {
|
||||
const pictureMesh = findMesh('__X_PICTURE__');
|
||||
createInstance: ({ scene, options, model }) => {
|
||||
const pictureMesh = model.findMesh('__X_PICTURE__');
|
||||
pictureMesh.rotationQuaternion = null;
|
||||
|
||||
const pipeTopMesh = findMesh('__X_PIPE_TOP__');
|
||||
const pipeBottomMesh = findMesh('__X_PIPE_BOTTOM__');
|
||||
const ropeMesh = findMesh('__X_ROPE__');
|
||||
const pipeTopMesh = model.findMesh('__X_PIPE_TOP__');
|
||||
const pipeBottomMesh = model.findMesh('__X_PIPE_BOTTOM__');
|
||||
const ropeMesh = model.findMesh('__X_ROPE__');
|
||||
|
||||
const pictureMaterial = findMaterial('__X_PICTURE__');
|
||||
const pictureMaterial = model.findMaterial('__X_PICTURE__');
|
||||
|
||||
const updateUv = createPlaneUvMapper(pictureMesh);
|
||||
|
||||
@@ -81,7 +81,7 @@ export const tapestry = defineObject({
|
||||
pipeBottomMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
|
||||
ropeMesh.morphTargetManager!.getTargetByName('Width')!.influence = options.width;
|
||||
ropeMesh.morphTargetManager!.getTargetByName('Height')!.influence = options.height;
|
||||
meshUpdated();
|
||||
model.updated();
|
||||
|
||||
applyFit();
|
||||
};
|
||||
|
||||
@@ -21,8 +21,8 @@ export const wallClock = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'side',
|
||||
createInstance: ({ room, root, options, findMaterial }) => {
|
||||
const frameMaterial = findMaterial('__X_FRAME__');
|
||||
createInstance: ({ room, root, options, model }) => {
|
||||
const frameMaterial = model.findMaterial('__X_FRAME__');
|
||||
|
||||
const applyFrameColor = () => {
|
||||
const [r, g, b] = options.frameColor;
|
||||
|
||||
@@ -33,7 +33,7 @@ export const wallShelf = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'side',
|
||||
createInstance: ({ findMesh, options, root }) => {
|
||||
createInstance: ({ model, options, root }) => {
|
||||
const applyStyle = () => {
|
||||
const aMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_A__'));
|
||||
const bMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_B__'));
|
||||
@@ -56,7 +56,7 @@ export const wallShelf = defineObject({
|
||||
|
||||
applyStyle();
|
||||
|
||||
const bodyMesh = findMesh('__X_BODY__');
|
||||
const bodyMesh = model.findMesh('__X_BODY__');
|
||||
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||
const bodyTexture = bodyMaterial.albedoTexture as BABYLON.Texture;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ export const woodRingFloorLamp = defineObject({
|
||||
},
|
||||
},
|
||||
placement: 'floor',
|
||||
createInstance: ({ options, findMaterial }) => {
|
||||
const shadeMaterial = findMaterial('__X_SHADE__');
|
||||
createInstance: ({ options, model }) => {
|
||||
const shadeMaterial = model.findMaterial('__X_SHADE__');
|
||||
|
||||
const applyShadeColor = () => {
|
||||
const [r, g, b] = options.shadeColor;
|
||||
@@ -36,7 +36,7 @@ export const woodRingFloorLamp = defineObject({
|
||||
|
||||
applyShadeColor();
|
||||
|
||||
const bodyMaterial = findMaterial('__X_BODY__');
|
||||
const bodyMaterial = model.findMaterial('__X_BODY__');
|
||||
|
||||
const applyBodyColor = () => {
|
||||
const [r, g, b] = options.bodyColor;
|
||||
|
||||
Reference in New Issue
Block a user