mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-06 23:54:15 +02:00
wip
This commit is contained in:
@@ -271,7 +271,7 @@ type ObjectDef<OpSc extends OptionsSchema = OptionsSchema> = {
|
|||||||
root: BABYLON.Mesh;
|
root: BABYLON.Mesh;
|
||||||
options: Readonly<GetOptionsSchemaValues<OpSc>>;
|
options: Readonly<GetOptionsSchemaValues<OpSc>>;
|
||||||
model: ModelManager;
|
model: ModelManager;
|
||||||
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>>;
|
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>> | Promise<RoomObjectInstance<GetOptionsSchemaValues<OpSc>>>; // TODO: createInstanceをasyncにするのではなく、別にreadyみたいなものを返させる
|
||||||
};
|
};
|
||||||
|
|
||||||
export function defineObject<const OpSc extends OptionsSchema>(def: ObjectDef<OpSc>): ObjectDef<OpSc> {
|
export function defineObject<const OpSc extends OptionsSchema>(def: ObjectDef<OpSc>): ObjectDef<OpSc> {
|
||||||
@@ -1061,7 +1061,7 @@ export class RoomEngine {
|
|||||||
meshUpdated(meshes);
|
meshUpdated(meshes);
|
||||||
});
|
});
|
||||||
|
|
||||||
const objectInstance = def.createInstance({
|
const objectInstance = await def.createInstance({
|
||||||
room: this,
|
room: this,
|
||||||
scene: this.scene,
|
scene: this.scene,
|
||||||
root,
|
root,
|
||||||
@@ -1640,7 +1640,7 @@ export class RoomObjectPreviewEngine {
|
|||||||
|
|
||||||
meshUpdated(loaderResult.meshes);
|
meshUpdated(loaderResult.meshes);
|
||||||
|
|
||||||
const objectInstance = def.createInstance({
|
const objectInstance = await def.createInstance({
|
||||||
room: null,
|
room: null,
|
||||||
scene: this.scene,
|
scene: this.scene,
|
||||||
root,
|
root,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const allInOnePc = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ scene, options, model }) => {
|
createInstance: async ({ scene, options, model }) => {
|
||||||
const screenMesh = model.findMesh('__X_SCREEN__');
|
const screenMesh = model.findMesh('__X_SCREEN__');
|
||||||
|
|
||||||
const bodyMaterial = model.findMaterial('__X_BODY__');
|
const bodyMaterial = model.findMaterial('__X_BODY__');
|
||||||
@@ -70,7 +70,7 @@ export const allInOnePc = defineObject({
|
|||||||
|
|
||||||
applyFit();
|
applyFit();
|
||||||
|
|
||||||
const applyCustomPicture = () => {
|
const applyCustomPicture = () => new Promise<void>((resolve) => {
|
||||||
if (options.customPicture != null) {
|
if (options.customPicture != null) {
|
||||||
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
||||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||||
@@ -79,17 +79,17 @@ export const allInOnePc = defineObject({
|
|||||||
|
|
||||||
screenMaterial.emissiveTexture = tex;
|
screenMaterial.emissiveTexture = tex;
|
||||||
|
|
||||||
applyFit();
|
|
||||||
|
|
||||||
tex.onLoadObservable.addOnce(() => {
|
tex.onLoadObservable.addOnce(() => {
|
||||||
applyFit();
|
applyFit();
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
screenMaterial.emissiveTexture = null;
|
screenMaterial.emissiveTexture = null;
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
applyCustomPicture();
|
await applyCustomPicture();
|
||||||
|
|
||||||
const applyScreenBrightness = () => {
|
const applyScreenBrightness = () => {
|
||||||
const b = options.screenBrightness;
|
const b = options.screenBrightness;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const laptopPc = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ scene, options, model }) => {
|
createInstance: async ({ scene, options, model }) => {
|
||||||
const screenMesh = model.findMesh('__X_SCREEN__');
|
const screenMesh = model.findMesh('__X_SCREEN__');
|
||||||
const hutaNode = model.findTransformNode('__X_HUTA__');
|
const hutaNode = model.findTransformNode('__X_HUTA__');
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ export const laptopPc = defineObject({
|
|||||||
|
|
||||||
applyFit();
|
applyFit();
|
||||||
|
|
||||||
const applyCustomPicture = () => {
|
const applyCustomPicture = () => new Promise<void>((resolve) => {
|
||||||
if (options.customPicture != null) {
|
if (options.customPicture != null) {
|
||||||
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
||||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||||
@@ -88,17 +88,17 @@ export const laptopPc = defineObject({
|
|||||||
|
|
||||||
screenMaterial.emissiveTexture = tex;
|
screenMaterial.emissiveTexture = tex;
|
||||||
|
|
||||||
applyFit();
|
|
||||||
|
|
||||||
tex.onLoadObservable.addOnce(() => {
|
tex.onLoadObservable.addOnce(() => {
|
||||||
applyFit();
|
applyFit();
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
screenMaterial.emissiveTexture = null;
|
screenMaterial.emissiveTexture = null;
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
applyCustomPicture();
|
await applyCustomPicture();
|
||||||
|
|
||||||
const applyScreenBrightness = () => {
|
const applyScreenBrightness = () => {
|
||||||
const b = options.screenBrightness;
|
const b = options.screenBrightness;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export const pictureFrame = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'side',
|
placement: 'side',
|
||||||
createInstance: ({ scene, options, model }) => {
|
createInstance: async ({ scene, options, model }) => {
|
||||||
const frameMesh = model.findMesh('__X_FRAME__');
|
const frameMesh = model.findMesh('__X_FRAME__');
|
||||||
frameMesh.rotationQuaternion = null;
|
frameMesh.rotationQuaternion = null;
|
||||||
const matMesh = model.findMesh('__X_MAT__');
|
const matMesh = model.findMesh('__X_MAT__');
|
||||||
@@ -156,7 +156,7 @@ export const pictureFrame = defineObject({
|
|||||||
|
|
||||||
applyDepth();
|
applyDepth();
|
||||||
|
|
||||||
const applyCustomPicture = () => {
|
const applyCustomPicture = () => new Promise<void>((resolve) => {
|
||||||
if (options.customPicture != null) {
|
if (options.customPicture != null) {
|
||||||
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
||||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||||
@@ -165,18 +165,18 @@ export const pictureFrame = defineObject({
|
|||||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||||
pictureMaterial.albedoTexture = tex;
|
pictureMaterial.albedoTexture = tex;
|
||||||
|
|
||||||
applyFit();
|
|
||||||
|
|
||||||
tex.onLoadObservable.addOnce(() => {
|
tex.onLoadObservable.addOnce(() => {
|
||||||
applyFit();
|
applyFit();
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
||||||
pictureMaterial.albedoTexture = null;
|
pictureMaterial.albedoTexture = null;
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
applyCustomPicture();
|
await applyCustomPicture();
|
||||||
|
|
||||||
const frameMaterial = model.findMaterial('__X_FRAME__');
|
const frameMaterial = model.findMaterial('__X_FRAME__');
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const poster = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'side',
|
placement: 'side',
|
||||||
createInstance: ({ scene, options, model }) => {
|
createInstance: async ({ scene, options, model }) => {
|
||||||
const pictureMesh = model.findMesh('__X_PICTURE__');
|
const pictureMesh = model.findMesh('__X_PICTURE__');
|
||||||
pictureMesh.rotationQuaternion = null;
|
pictureMesh.rotationQuaternion = null;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ export const poster = defineObject({
|
|||||||
|
|
||||||
applySize();
|
applySize();
|
||||||
|
|
||||||
const applyCustomPicture = () => {
|
const applyCustomPicture = () => new Promise<void>((resolve) => {
|
||||||
if (options.customPicture != null) {
|
if (options.customPicture != null) {
|
||||||
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
||||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||||
@@ -93,18 +93,18 @@ export const poster = defineObject({
|
|||||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||||
pictureMaterial.albedoTexture = tex;
|
pictureMaterial.albedoTexture = tex;
|
||||||
|
|
||||||
applyFit();
|
|
||||||
|
|
||||||
tex.onLoadObservable.addOnce(() => {
|
tex.onLoadObservable.addOnce(() => {
|
||||||
applyFit();
|
applyFit();
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
||||||
pictureMaterial.albedoTexture = null;
|
pictureMaterial.albedoTexture = null;
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
applyCustomPicture();
|
await applyCustomPicture();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
onInited: () => {
|
onInited: () => {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export const tabletopPictureFrame = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
createInstance: ({ scene, options, model }) => {
|
createInstance: async ({ scene, options, model }) => {
|
||||||
const frameMesh = model.findMesh('__X_FRAME__');
|
const frameMesh = model.findMesh('__X_FRAME__');
|
||||||
frameMesh.rotationQuaternion = null;
|
frameMesh.rotationQuaternion = null;
|
||||||
const matMesh = model.findMesh('__X_MAT__');
|
const matMesh = model.findMesh('__X_MAT__');
|
||||||
@@ -161,7 +161,7 @@ export const tabletopPictureFrame = defineObject({
|
|||||||
|
|
||||||
applyDepth();
|
applyDepth();
|
||||||
|
|
||||||
const applyCustomPicture = () => {
|
const applyCustomPicture = () => new Promise<void>((resolve) => {
|
||||||
if (options.customPicture != null) {
|
if (options.customPicture != null) {
|
||||||
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
||||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||||
@@ -170,18 +170,18 @@ export const tabletopPictureFrame = defineObject({
|
|||||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||||
pictureMaterial.albedoTexture = tex;
|
pictureMaterial.albedoTexture = tex;
|
||||||
|
|
||||||
applyFit();
|
|
||||||
|
|
||||||
tex.onLoadObservable.addOnce(() => {
|
tex.onLoadObservable.addOnce(() => {
|
||||||
applyFit();
|
applyFit();
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
||||||
pictureMaterial.albedoTexture = null;
|
pictureMaterial.albedoTexture = null;
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
applyCustomPicture();
|
await applyCustomPicture();
|
||||||
|
|
||||||
const frameMaterial = model.findMaterial('__X_FRAME__');
|
const frameMaterial = model.findMaterial('__X_FRAME__');
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const tapestry = defineObject({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
placement: 'side',
|
placement: 'side',
|
||||||
createInstance: ({ scene, options, model }) => {
|
createInstance: async ({ scene, options, model }) => {
|
||||||
const pictureMesh = model.findMesh('__X_PICTURE__');
|
const pictureMesh = model.findMesh('__X_PICTURE__');
|
||||||
pictureMesh.rotationQuaternion = null;
|
pictureMesh.rotationQuaternion = null;
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ export const tapestry = defineObject({
|
|||||||
|
|
||||||
applySize();
|
applySize();
|
||||||
|
|
||||||
const applyCustomPicture = () => {
|
const applyCustomPicture = () => new Promise<void>((resolve) => {
|
||||||
if (options.customPicture != null) {
|
if (options.customPicture != null) {
|
||||||
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
||||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||||
@@ -97,18 +97,18 @@ export const tapestry = defineObject({
|
|||||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||||
pictureMaterial.albedoTexture = tex;
|
pictureMaterial.albedoTexture = tex;
|
||||||
|
|
||||||
applyFit();
|
|
||||||
|
|
||||||
tex.onLoadObservable.addOnce(() => {
|
tex.onLoadObservable.addOnce(() => {
|
||||||
applyFit();
|
applyFit();
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
||||||
pictureMaterial.albedoTexture = null;
|
pictureMaterial.albedoTexture = null;
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
applyCustomPicture();
|
await applyCustomPicture();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
onInited: () => {
|
onInited: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user