diff --git a/app/pages/PageEnigma/js/editor.ts b/app/pages/PageEnigma/js/editor.ts index 82ad942467..e0a4aa2da2 100644 --- a/app/pages/PageEnigma/js/editor.ts +++ b/app/pages/PageEnigma/js/editor.ts @@ -488,6 +488,7 @@ class Editor { this.activeScene, ); const scene_json = await proxyScene.saveToScene(); + console.log("scene_json", scene_json); const proxyTimeline = new StoryTellerProxyTimeline( this.version, diff --git a/app/pages/PageEnigma/js/scene.ts b/app/pages/PageEnigma/js/scene.ts index bfc95e198c..043daf5e8c 100644 --- a/app/pages/PageEnigma/js/scene.ts +++ b/app/pages/PageEnigma/js/scene.ts @@ -51,6 +51,10 @@ class Scene { //obj.type = "Object3D"; obj.name = name; obj.position.copy(pos); + obj.userData["color"] = "#FFFFFF"; + obj.userData["metalness"] = 0.0; + obj.userData["shininess"] = 0.5; + obj.userData["specular"] = 0.0; this.scene.add(obj); return obj.uuid; } @@ -138,21 +142,19 @@ class Scene { if (c instanceof THREE.Mesh) { c.material.metalness = 0.0; c.material.specular = 0.5; + c.material.shininess = 0.0; c.castShadow = true; c.receiveShadow = true; c.frustumCulled = false; c.material.transparent = false; } }); - //console.log(child); - //if (child.type == "Group") { - // if (auto_add) { child.children.forEach(element => { - // this.scene.add(element); - // }); } - // resolve(child); - //} child.frustumCulled = false; child.userData["media_id"] = media_id; + child.userData["color"] = "#FFFFFF"; + child.userData["metalness"] = 0.0; + child.userData["shininess"] = 0.5; + child.userData["specular"] = 0.5; if (auto_add) { this.scene.add(child); } resolve(child); }); @@ -179,6 +181,7 @@ class Scene { resolve(child.children[0]); return; } + child.userData["color"] = "#FFFFFF"; if (auto_add) { this.scene.add(child); } resolve(child); }); diff --git a/app/pages/PageEnigma/proxy/storyteller_proxy_3d_object.ts b/app/pages/PageEnigma/proxy/storyteller_proxy_3d_object.ts index d61734c79a..4f9f73ec6d 100644 --- a/app/pages/PageEnigma/proxy/storyteller_proxy_3d_object.ts +++ b/app/pages/PageEnigma/proxy/storyteller_proxy_3d_object.ts @@ -21,6 +21,10 @@ export interface ObjectJSON { object_uuid: string; object_user_data_name: string; media_file_token: string; + color: string; + metalness: number, + shininess: number, + specular: number, } export class StoryTellerProxy3DObject { @@ -34,6 +38,10 @@ export class StoryTellerProxy3DObject { object_name: string; object_user_data_name: string; // changable name media_file_token: string; + color: string; + metalness: number; + shininess: number; + specular: number; constructor( version: number, @@ -49,6 +57,19 @@ export class StoryTellerProxy3DObject { this.object_name = ""; this.object_user_data_name = ""; this.object_uuid = ""; + + this.color = ""; + + this.metalness = 0.0; + this.shininess = 0.0; + this.specular = 0.5; + } + + getColorAsHexString(object: THREE.Object3D): string { + if (object instanceof THREE.Mesh && object.material instanceof THREE.MeshBasicMaterial) { + return '#' + object.material.color.getHexString(); + } + return "#FFFFFF" } public async initialize(object: THREE.Object3D) { @@ -59,6 +80,10 @@ export class StoryTellerProxy3DObject { this.object_name = object.name; this.object_user_data_name = object.userData.name; this.object_uuid = object.uuid; + this.color = object.userData["color"]; + this.metalness = object.userData["metalness"]; + this.shininess = object.userData["shininess"]; + this.specular = object.userData["specular"]; } public async toJSON(): Promise { @@ -83,6 +108,10 @@ export class StoryTellerProxy3DObject { object_uuid: this.object_uuid, object_user_data_name: this.object_user_data_name, media_file_token: this.media_file_token, + color: this.color, + metalness: this.metalness, + shininess: this.shininess, + specular: this.specular, }; return json; } diff --git a/app/pages/PageEnigma/proxy/storyteller_proxy_scene.ts b/app/pages/PageEnigma/proxy/storyteller_proxy_scene.ts index c5fdddc1d9..7383c70d8a 100644 --- a/app/pages/PageEnigma/proxy/storyteller_proxy_scene.ts +++ b/app/pages/PageEnigma/proxy/storyteller_proxy_scene.ts @@ -38,6 +38,10 @@ export class StoryTellerProxyScene { proxyObject3D.object_user_data_name = child.userData.name; proxyObject3D.object_name = child.name; proxyObject3D.object_uuid = child.uuid; + proxyObject3D.color = child.userData["color"]; + proxyObject3D.metalness = child.userData["metalness"]; + proxyObject3D.shininess = child.userData["shininess"]; + proxyObject3D.specular = child.userData["specular"]; const json_data = await proxyObject3D.toJSON(); results.push(json_data); }