@tomorrowevening/hermes 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/hermes.js +2533 -718
- package/dist/hermes.umd.cjs +88 -11
- package/dist/images/android-chrome-192x192.png +0 -0
- package/dist/images/android-chrome-512x512.png +0 -0
- package/dist/images/apple-touch-icon.png +0 -0
- package/dist/images/favicon-16x16.png +0 -0
- package/dist/images/favicon-32x32.png +0 -0
- package/dist/images/favicon.ico +0 -0
- package/dist/images/milkyWay/dark-s_nx.jpg +0 -0
- package/dist/images/milkyWay/dark-s_ny.jpg +0 -0
- package/dist/images/milkyWay/dark-s_nz.jpg +0 -0
- package/dist/images/milkyWay/dark-s_px.jpg +0 -0
- package/dist/images/milkyWay/dark-s_py.jpg +0 -0
- package/dist/images/milkyWay/dark-s_pz.jpg +0 -0
- package/dist/images/site.webmanifest +1 -0
- package/dist/images/uv_grid_opengl.jpg +0 -0
- package/dist/index-0a798fe4.js +6862 -0
- package/dist/index-7bad599d.css +1 -0
- package/dist/index.html +18 -0
- package/dist/models/Flair.fbx +0 -0
- package/dist/models/Thriller2.fbx +0 -0
- package/dist/models/Thriller4.fbx +0 -0
- package/dist/style.css +1 -1
- package/package.json +9 -4
- package/src/core/Application.ts +28 -36
- package/src/core/RemoteController.ts +148 -98
- package/src/core/remote/BaseRemote.ts +3 -3
- package/src/core/remote/RemoteComponents.ts +5 -8
- package/src/core/remote/RemoteTheatre.ts +56 -54
- package/src/core/remote/RemoteThree.ts +77 -0
- package/src/core/remote/RemoteTweakpane.ts +71 -78
- package/src/core/types.ts +14 -4
- package/src/editor/Editor.tsx +8 -6
- package/src/editor/components/Draggable.tsx +20 -20
- package/src/editor/components/DraggableItem.tsx +6 -6
- package/src/editor/components/Dropdown.tsx +22 -14
- package/src/editor/components/DropdownItem.tsx +19 -19
- package/src/editor/components/NavButton.tsx +1 -1
- package/src/editor/components/content.ts +2 -0
- package/src/editor/components/icons/CloseIcon.tsx +1 -1
- package/src/editor/components/icons/DragIcon.tsx +1 -1
- package/src/editor/global.ts +9 -4
- package/src/editor/sceneHierarchy/Accordion.tsx +40 -0
- package/src/editor/sceneHierarchy/ChildObject.tsx +17 -17
- package/src/editor/sceneHierarchy/ContainerObject.tsx +7 -8
- package/src/editor/sceneHierarchy/SceneHierarchy.tsx +52 -49
- package/src/editor/sceneHierarchy/ToggleBtn.tsx +26 -0
- package/src/editor/sceneHierarchy/inspector/Inspector.tsx +82 -0
- package/src/editor/sceneHierarchy/inspector/InspectorField.tsx +178 -0
- package/src/editor/sceneHierarchy/inspector/InspectorGroup.tsx +55 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/CameraWindow.tsx +61 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/InfiniteGridHelper.ts +24 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/InfiniteGridMaterial.ts +127 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/MultiView.scss +93 -0
- package/src/editor/sceneHierarchy/inspector/MultiView/MultiView.tsx +450 -0
- package/src/editor/sceneHierarchy/inspector/SceneInspector.tsx +72 -0
- package/src/editor/sceneHierarchy/inspector/inspector.scss +150 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectCamera.tsx +75 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectLight.tsx +62 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectMaterial.tsx +340 -0
- package/src/editor/sceneHierarchy/inspector/utils/InspectTransform.tsx +124 -0
- package/src/editor/sceneHierarchy/types.ts +116 -5
- package/src/editor/sceneHierarchy/utils.ts +207 -11
- package/src/editor/scss/_debug.scss +9 -19
- package/src/editor/scss/_dropdown.scss +1 -0
- package/src/editor/scss/_sceneHierarchy.scss +148 -48
- package/src/editor/scss/index.scss +13 -6
- package/src/editor/utils.ts +42 -5
- package/src/example/CustomEditor.tsx +40 -0
- package/src/example/components/App.tsx +164 -0
- package/src/example/constants.ts +40 -9
- package/src/example/main.tsx +5 -45
- package/src/example/three/CustomMaterial.ts +58 -0
- package/src/example/three/ExampleScene.ts +176 -0
- package/src/example/three/FBXAnimation.ts +39 -0
- package/src/index.ts +23 -14
- package/types/core/Application.d.ts +7 -13
- package/types/core/remote/RemoteComponents.d.ts +0 -2
- package/types/core/remote/RemoteThree.d.ts +12 -0
- package/types/core/remote/RemoteTweakpane.d.ts +3 -3
- package/types/core/types.d.ts +4 -3
- package/types/editor/Editor.d.ts +2 -1
- package/types/editor/components/content.d.ts +2 -0
- package/types/editor/global.d.ts +7 -2
- package/types/editor/sceneHierarchy/Accordion.d.ts +10 -0
- package/types/editor/sceneHierarchy/SceneHierarchy.d.ts +5 -5
- package/types/editor/sceneHierarchy/ToggleBtn.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/Inspector.d.ts +3 -0
- package/types/editor/sceneHierarchy/inspector/InspectorField.d.ts +13 -0
- package/types/editor/sceneHierarchy/inspector/InspectorGroup.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/CameraWindow.d.ts +16 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/InfiniteGridHelper.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/InfiniteGridMaterial.d.ts +13 -0
- package/types/editor/sceneHierarchy/inspector/MultiView/MultiView.d.ts +11 -0
- package/types/editor/sceneHierarchy/inspector/SceneInspector.d.ts +7 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectCamera.d.ts +3 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectLight.d.ts +3 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectMaterial.d.ts +8 -0
- package/types/editor/sceneHierarchy/inspector/utils/InspectTransform.d.ts +3 -0
- package/types/editor/sceneHierarchy/types.d.ts +98 -7
- package/types/editor/sceneHierarchy/utils.d.ts +7 -1
- package/types/editor/utils.d.ts +3 -0
- package/types/example/CustomEditor.d.ts +1 -0
- package/types/example/constants.d.ts +15 -3
- package/types/example/three/CustomMaterial.d.ts +5 -0
- package/types/example/three/ExampleScene.d.ts +18 -0
- package/types/example/three/FBXAnimation.d.ts +6 -0
- package/types/index.d.ts +8 -0
- package/src/example/App.tsx +0 -88
- package/types/core/remote/RemoteDebug.d.ts +0 -23
- package/types/debug/Editor.d.ts +0 -8
- package/types/debug/components/Draggable.d.ts +0 -2
- package/types/debug/components/DraggableItem.d.ts +0 -2
- package/types/debug/components/Dropdown.d.ts +0 -2
- package/types/debug/components/DropdownItem.d.ts +0 -2
- package/types/debug/components/NavButton.d.ts +0 -5
- package/types/debug/components/icons/CloseIcon.d.ts +0 -2
- package/types/debug/components/icons/DragIcon.d.ts +0 -2
- package/types/debug/components/types.d.ts +0 -31
- package/types/debug/global.d.ts +0 -9
- package/types/debug/sceneHierarchy/ChildObject.d.ts +0 -2
- package/types/debug/sceneHierarchy/ContainerObject.d.ts +0 -2
- package/types/debug/sceneHierarchy/SceneHierarchy.d.ts +0 -13
- package/types/debug/sceneHierarchy/types.d.ts +0 -8
- package/types/debug/sceneHierarchy/utils.d.ts +0 -2
- package/types/debug/utils.d.ts +0 -4
- package/types/library.d.ts +0 -14
- /package/src/example/{App.css → components/App.css} +0 -0
- /package/types/example/{App.d.ts → components/App.d.ts} +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
import { textureFromSrc } from "@/editor/sceneHierarchy/utils";
|
2
|
+
import { ShaderMaterial, Texture } from "three";
|
3
|
+
|
4
|
+
const vertex = `varying vec2 vUv;
|
5
|
+
|
6
|
+
void main() {
|
7
|
+
vUv = uv;
|
8
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
9
|
+
}`;
|
10
|
+
|
11
|
+
const fragment = `uniform float time;
|
12
|
+
uniform float opacity;
|
13
|
+
uniform sampler2D map;
|
14
|
+
varying vec2 vUv;
|
15
|
+
|
16
|
+
#define MIN_ALPHA 2.0 / 255.0
|
17
|
+
|
18
|
+
void main() {
|
19
|
+
if (opacity < MIN_ALPHA) discard;
|
20
|
+
vec3 gradient = 0.5 + 0.5 * cos(time + vUv.xyx + vec3(0.0, 2.0, 4.0));
|
21
|
+
vec3 image = texture2D(map, vUv * 10.0).rgb;
|
22
|
+
// vec3 col = mix(image, gradient, 0.15);
|
23
|
+
vec3 col = image + gradient;
|
24
|
+
gl_FragColor = vec4(col, opacity);
|
25
|
+
}`;
|
26
|
+
|
27
|
+
const smile = `data:image/png;base64,R0lGODlhCAAIAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDEgNzkuMTQ2Mjg5OTc3NywgMjAyMy8wNi8yNS0yMzo1NzoxNCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDI1LjIgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NjVENjQyODM4QTYzMTFFRUJFQTBFOTJFNjA1OTQ5N0YiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NjVENjQyODQ4QTYzMTFFRUJFQTBFOTJFNjA1OTQ5N0YiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo2NUQ2NDI4MThBNjMxMUVFQkVBMEU5MkU2MDU5NDk3RiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo2NUQ2NDI4MjhBNjMxMUVFQkVBMEU5MkU2MDU5NDk3RiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PgH//v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dzb2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vLu6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZmJeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAAAAAAALAAAAAAIAAgAAAIOjH8AprzRkHyspqSoNAUAOw==`;
|
28
|
+
|
29
|
+
export default class CustomMaterial extends ShaderMaterial {
|
30
|
+
constructor() {
|
31
|
+
super({
|
32
|
+
vertexShader: vertex,
|
33
|
+
fragmentShader: fragment,
|
34
|
+
name: 'ExampleScene/SimpleShader',
|
35
|
+
transparent: true,
|
36
|
+
uniforms: {
|
37
|
+
opacity: {
|
38
|
+
value: 1,
|
39
|
+
},
|
40
|
+
time: {
|
41
|
+
value: 0,
|
42
|
+
},
|
43
|
+
map: {
|
44
|
+
value: null,
|
45
|
+
}
|
46
|
+
},
|
47
|
+
});
|
48
|
+
|
49
|
+
textureFromSrc(smile).then((texture: Texture) => {
|
50
|
+
this.uniforms.map.value = texture;
|
51
|
+
});
|
52
|
+
}
|
53
|
+
|
54
|
+
update(delta: number) {
|
55
|
+
this.uniforms.opacity.value = this.opacity;
|
56
|
+
this.uniforms.time.value += delta;
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,176 @@
|
|
1
|
+
import { BackSide, CircleGeometry, CubeTexture, CubeTextureLoader, DirectionalLight, HemisphereLight, Mesh, MeshBasicMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, Object3D, PerspectiveCamera, PlaneGeometry, RepeatWrapping, Scene, SphereGeometry, Texture, TextureLoader } from 'three';
|
2
|
+
import CustomMaterial from './CustomMaterial';
|
3
|
+
import { hierarchyUUID } from '@/editor/utils';
|
4
|
+
import { IS_DEV, app } from '../constants';
|
5
|
+
import FBXAnimation from './FBXAnimation';
|
6
|
+
|
7
|
+
export default class ExampleScene extends Scene {
|
8
|
+
camera!: PerspectiveCamera;
|
9
|
+
envMap: CubeTexture;
|
10
|
+
dance0!: FBXAnimation;
|
11
|
+
dance1!: FBXAnimation;
|
12
|
+
dance2!: FBXAnimation;
|
13
|
+
|
14
|
+
private customMat!: CustomMaterial;
|
15
|
+
private lastUpdate = -1;
|
16
|
+
|
17
|
+
constructor() {
|
18
|
+
super();
|
19
|
+
this.name = 'TestScene';
|
20
|
+
this.envMap = new CubeTextureLoader()
|
21
|
+
.setPath('images/milkyWay/')
|
22
|
+
.load([
|
23
|
+
'dark-s_px.jpg',
|
24
|
+
'dark-s_nx.jpg',
|
25
|
+
'dark-s_py.jpg',
|
26
|
+
'dark-s_ny.jpg',
|
27
|
+
'dark-s_pz.jpg',
|
28
|
+
'dark-s_nz.jpg'
|
29
|
+
], (value: CubeTexture) => {
|
30
|
+
this.background = value;
|
31
|
+
|
32
|
+
if (app.editor) {
|
33
|
+
const bg = new Mesh(new SphereGeometry(), new MeshBasicMaterial({ envMap: value, side: BackSide }));
|
34
|
+
bg.name = 'bg';
|
35
|
+
bg.scale.setScalar(1000);
|
36
|
+
this.add(bg);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
this.createCameras();
|
41
|
+
this.createLights();
|
42
|
+
this.createWorld();
|
43
|
+
|
44
|
+
this.lastUpdate = Date.now();
|
45
|
+
if (IS_DEV) hierarchyUUID(this);
|
46
|
+
}
|
47
|
+
|
48
|
+
private createCameras() {
|
49
|
+
const cameras = new Object3D();
|
50
|
+
cameras.name = 'cameras';
|
51
|
+
this.add(cameras);
|
52
|
+
|
53
|
+
this.camera = new PerspectiveCamera(60, 1, 1, 2000);
|
54
|
+
this.camera.name = 'Main';
|
55
|
+
this.camera.position.set(0, 200, 300);
|
56
|
+
this.camera.lookAt(0, 0, 0);
|
57
|
+
cameras.add(this.camera);
|
58
|
+
}
|
59
|
+
|
60
|
+
private createLights() {
|
61
|
+
const lights = new Object3D();
|
62
|
+
lights.name = 'lights';
|
63
|
+
this.add(lights);
|
64
|
+
|
65
|
+
const sun = new DirectionalLight();
|
66
|
+
sun.name = 'sun';
|
67
|
+
sun.castShadow = true;
|
68
|
+
sun.position.set(0, 50, 50);
|
69
|
+
const shadow = 256;
|
70
|
+
sun.shadow.camera.top = shadow;
|
71
|
+
sun.shadow.camera.bottom = -shadow;
|
72
|
+
sun.shadow.camera.left = - shadow;
|
73
|
+
sun.shadow.camera.right = shadow;
|
74
|
+
sun.shadow.mapSize.width = 1024;
|
75
|
+
sun.shadow.mapSize.height = 1024;
|
76
|
+
sun.shadow.camera.near = 10;
|
77
|
+
sun.shadow.camera.far = 1000;
|
78
|
+
sun.shadow.bias = 0.0001;
|
79
|
+
lights.add(sun);
|
80
|
+
|
81
|
+
const hemi = new HemisphereLight(0x6fb4e2, 0xc46d27, 0.5);
|
82
|
+
hemi.name = 'hemi';
|
83
|
+
lights.add(hemi);
|
84
|
+
}
|
85
|
+
|
86
|
+
private createWorld() {
|
87
|
+
const world = new Object3D();
|
88
|
+
world.name = 'world';
|
89
|
+
this.add(world);
|
90
|
+
|
91
|
+
const floorMaterial = new MeshPhongMaterial();
|
92
|
+
const floor = new Mesh(new CircleGeometry(500, 36), floorMaterial);
|
93
|
+
floor.name = 'floor';
|
94
|
+
floor.receiveShadow = true;
|
95
|
+
floor.rotateX(-Math.PI / 2);
|
96
|
+
world.add(floor);
|
97
|
+
new TextureLoader().load('images/uv_grid_opengl.jpg', (texture: Texture) => {
|
98
|
+
texture.wrapS = RepeatWrapping;
|
99
|
+
texture.wrapT = RepeatWrapping;
|
100
|
+
texture.repeat.setScalar(10);
|
101
|
+
texture.needsUpdate = true;
|
102
|
+
floorMaterial.map = texture;
|
103
|
+
floorMaterial.needsUpdate = true;
|
104
|
+
});
|
105
|
+
|
106
|
+
this.dance0 = new FBXAnimation('Thriller2.fbx');
|
107
|
+
this.dance0.position.set(-150, 0, -175);
|
108
|
+
world.add(this.dance0);
|
109
|
+
|
110
|
+
this.dance1 = new FBXAnimation('Flair.fbx');
|
111
|
+
this.dance1.position.set(0, 0, 0);
|
112
|
+
world.add(this.dance1);
|
113
|
+
|
114
|
+
this.dance2 = new FBXAnimation('Thriller4.fbx');
|
115
|
+
this.dance2.position.set(150, 0, -185);
|
116
|
+
world.add(this.dance2);
|
117
|
+
|
118
|
+
this.createTestMaterials(world);
|
119
|
+
}
|
120
|
+
|
121
|
+
private createTestMaterials(world: Object3D) {
|
122
|
+
const geom = new SphereGeometry(20);
|
123
|
+
|
124
|
+
const items: Mesh[] = [];
|
125
|
+
const mesh = new Mesh(geom, new MeshBasicMaterial({ name: 'BasicMaterial', transparent: true }));
|
126
|
+
mesh.name = 'Basic';
|
127
|
+
world.add(mesh);
|
128
|
+
items.push(mesh);
|
129
|
+
|
130
|
+
const mesh2 = new Mesh(geom, new MeshMatcapMaterial({ transparent: true }));
|
131
|
+
mesh2.name = 'Matcap';
|
132
|
+
world.add(mesh2);
|
133
|
+
items.push(mesh2);
|
134
|
+
|
135
|
+
const mesh5 = new Mesh(geom, new MeshPhongMaterial({ name: 'PhongMaterial', transparent: true }));
|
136
|
+
mesh5.name = 'Phong';
|
137
|
+
world.add(mesh5);
|
138
|
+
items.push(mesh5);
|
139
|
+
|
140
|
+
const mesh3 = new Mesh(geom, new MeshPhysicalMaterial({ name: 'PhysicalMaterial', transparent: true }));
|
141
|
+
mesh3.name = 'Physical';
|
142
|
+
world.add(mesh3);
|
143
|
+
items.push(mesh3);
|
144
|
+
|
145
|
+
// CustomMaterial
|
146
|
+
this.customMat = new CustomMaterial();
|
147
|
+
const mesh4 = new Mesh(geom, this.customMat);
|
148
|
+
mesh4.name = 'Shader';
|
149
|
+
world.add(mesh4);
|
150
|
+
items.push(mesh4);
|
151
|
+
|
152
|
+
const spacing = 50;
|
153
|
+
const total = items.length;
|
154
|
+
const offset = ((total - 1) / 2) * spacing;
|
155
|
+
for (let i = 0; i < total; i++) {
|
156
|
+
const x = i * spacing - offset;
|
157
|
+
items[i].position.set(x, 100, -150);
|
158
|
+
items[i].castShadow = true;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
resize(width: number, height: number) {
|
163
|
+
this.camera.aspect = width / height;
|
164
|
+
this.camera.updateProjectionMatrix();
|
165
|
+
}
|
166
|
+
|
167
|
+
update() {
|
168
|
+
const now = Date.now();
|
169
|
+
const delta = (now - this.lastUpdate) / 1000;
|
170
|
+
this.lastUpdate = now;
|
171
|
+
this.customMat.update(delta);
|
172
|
+
this.dance0.update(delta);
|
173
|
+
this.dance1.update(delta);
|
174
|
+
this.dance2.update(delta);
|
175
|
+
}
|
176
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { AnimationMixer, Group, Object3D } from "three";
|
2
|
+
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
|
3
|
+
|
4
|
+
export default class FBXAnimation extends Object3D {
|
5
|
+
mixer?: AnimationMixer;
|
6
|
+
|
7
|
+
constructor(source: string) {
|
8
|
+
super();
|
9
|
+
this.name = source.replaceAll(' ', '').split('.')[0];
|
10
|
+
this.scale.setScalar(0.5);
|
11
|
+
|
12
|
+
new FBXLoader()
|
13
|
+
.setPath('./models/')
|
14
|
+
.loadAsync(source)
|
15
|
+
.then((model: Group) => {
|
16
|
+
this.add(model);
|
17
|
+
|
18
|
+
// Shadows
|
19
|
+
model.traverse((obj: Object3D) => {
|
20
|
+
if (obj['isMesh']) {
|
21
|
+
obj.castShadow = true;
|
22
|
+
obj.receiveShadow = true;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
|
26
|
+
this.mixer = new AnimationMixer(model);
|
27
|
+
const action = this.mixer.clipAction(model.animations[0]);
|
28
|
+
action.play();
|
29
|
+
})
|
30
|
+
.catch((reason: any) => {
|
31
|
+
console.log(`Couldn't load:`, source);
|
32
|
+
console.log(reason);
|
33
|
+
})
|
34
|
+
}
|
35
|
+
|
36
|
+
update(delta: number) {
|
37
|
+
this.mixer?.update(delta);
|
38
|
+
}
|
39
|
+
}
|
package/src/index.ts
CHANGED
@@ -1,16 +1,25 @@
|
|
1
1
|
// Core
|
2
|
-
export { default as Application } from './core/Application'
|
3
|
-
export { debugDispatcher, ToolEvents } from './editor/global'
|
4
|
-
export { default as BaseRemote } from './core/remote/BaseRemote'
|
5
|
-
export { default as RemoteComponents } from './core/remote/RemoteComponents'
|
6
|
-
export { default as RemoteTheatre } from './core/remote/RemoteTheatre'
|
7
|
-
export { default as
|
2
|
+
export { default as Application } from './core/Application';
|
3
|
+
export { debugDispatcher, ToolEvents } from './editor/global';
|
4
|
+
export { default as BaseRemote } from './core/remote/BaseRemote';
|
5
|
+
export { default as RemoteComponents } from './core/remote/RemoteComponents';
|
6
|
+
export { default as RemoteTheatre } from './core/remote/RemoteTheatre';
|
7
|
+
export { default as RemoteThree } from './core/remote/RemoteThree';
|
8
|
+
export { default as RemoteTweakpane } from './core/remote/RemoteTweakpane';
|
8
9
|
// Components
|
9
|
-
export { default as NavButton } from './editor/components/NavButton'
|
10
|
-
export { default as DraggableItem } from './editor/components/DraggableItem'
|
11
|
-
export { default as Draggable } from './editor/components/Draggable'
|
12
|
-
export { default as DropdownItem } from './editor/components/DropdownItem'
|
13
|
-
export { default as Dropdown } from './editor/components/Dropdown'
|
14
|
-
export { default as RemoteController } from './core/RemoteController'
|
15
|
-
|
16
|
-
export { default as
|
10
|
+
export { default as NavButton } from './editor/components/NavButton';
|
11
|
+
export { default as DraggableItem } from './editor/components/DraggableItem';
|
12
|
+
export { default as Draggable } from './editor/components/Draggable';
|
13
|
+
export { default as DropdownItem } from './editor/components/DropdownItem';
|
14
|
+
export { default as Dropdown } from './editor/components/Dropdown';
|
15
|
+
export { default as RemoteController } from './core/RemoteController';
|
16
|
+
// RemoteThree
|
17
|
+
export { default as SceneHierarchy } from './editor/sceneHierarchy/SceneHierarchy';
|
18
|
+
export { default as Accordion } from './editor/sceneHierarchy/Accordion';
|
19
|
+
export { default as ChildObject } from './editor/sceneHierarchy/ChildObject';
|
20
|
+
export { default as ContainerObject } from './editor/sceneHierarchy/ContainerObject';
|
21
|
+
export { default as Inspector } from './editor/sceneHierarchy/inspector/Inspector';
|
22
|
+
export { default as SceneInspector } from './editor/sceneHierarchy/inspector/SceneInspector';
|
23
|
+
export { default as MultiView } from './editor/sceneHierarchy/inspector/MultiView/MultiView';
|
24
|
+
export { default as InfiniteGridHelper } from './editor/sceneHierarchy/inspector/MultiView/InfiniteGridHelper';
|
25
|
+
export { default as Editor } from './editor/Editor';
|
@@ -1,21 +1,15 @@
|
|
1
|
-
import
|
2
|
-
import RemoteComponents from './remote/RemoteComponents';
|
3
|
-
import RemoteTheatre from './remote/RemoteTheatre';
|
4
|
-
import RemoteTweakpane from './remote/RemoteTweakpane';
|
1
|
+
import BaseRemote from './remote/BaseRemote';
|
5
2
|
import type { ApplicationMode, BroadcastCallback, BroadcastData } from './types';
|
6
3
|
export default class Application {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
constructor(debugEnabled: boolean, editorHashtag: string);
|
13
|
-
setupComponents(): void;
|
14
|
-
setupGUI(): void;
|
15
|
-
setupTheatre(projectName: string, projectConfig?: IProjectConfig | undefined): void;
|
4
|
+
channel?: BroadcastChannel | undefined;
|
5
|
+
components: Map<string, any>;
|
6
|
+
protected _mode: ApplicationMode;
|
7
|
+
constructor(name: string, debugEnabled: boolean, editorHashtag: string);
|
8
|
+
addComponent(name: string, component: BaseRemote): void;
|
16
9
|
dispose(): void;
|
17
10
|
send(data: BroadcastData): void;
|
18
11
|
listen(callback: BroadcastCallback): void;
|
12
|
+
get mode(): ApplicationMode;
|
19
13
|
get editor(): boolean;
|
20
14
|
set editor(value: boolean);
|
21
15
|
}
|
@@ -1,7 +1,5 @@
|
|
1
|
-
import Application from '../Application';
|
2
1
|
import BaseRemote from './BaseRemote';
|
3
2
|
export default class RemoteComponents extends BaseRemote {
|
4
|
-
constructor(app: Application);
|
5
3
|
selectDropdown(dropdown: string, value: any): void;
|
6
4
|
updateDropdown(dropdown: string, list: string[]): void;
|
7
5
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Scene } from 'three';
|
2
|
+
import BaseRemote from './BaseRemote';
|
3
|
+
export default class RemoteThree extends BaseRemote {
|
4
|
+
scene?: Scene;
|
5
|
+
getObject(uuid: string): void;
|
6
|
+
setObject(value: any): void;
|
7
|
+
requestMethod(uuid: string, key: string, value?: any): void;
|
8
|
+
updateObject(uuid: string, key: string, value: any): void;
|
9
|
+
createTexture(uuid: string, key: string, value: any): void;
|
10
|
+
getScene(): void;
|
11
|
+
setScene(value: Scene): void;
|
12
|
+
}
|
@@ -3,14 +3,12 @@ import Application from '../Application';
|
|
3
3
|
import BaseRemote from './BaseRemote';
|
4
4
|
import type { DataUpdateCallback, VoidCallback } from '../types';
|
5
5
|
export default class RemoteTweakpane extends BaseRemote {
|
6
|
-
appTab: any;
|
7
|
-
systemTab: any;
|
8
|
-
utilsTab: any;
|
9
6
|
bindCBs: Map<string, DataUpdateCallback>;
|
10
7
|
buttonCBs: Map<string, VoidCallback>;
|
11
8
|
protected pane?: Pane | undefined;
|
12
9
|
protected appCallbacks: number;
|
13
10
|
protected editorCallbacks: number;
|
11
|
+
protected inspectorFolder: any;
|
14
12
|
constructor(app: Application);
|
15
13
|
protected createGUI(): void;
|
16
14
|
dispose(): void;
|
@@ -20,4 +18,6 @@ export default class RemoteTweakpane extends BaseRemote {
|
|
20
18
|
triggerBind(id: string, data: any): void;
|
21
19
|
button(name: string, callback: VoidCallback, parent?: any): void;
|
22
20
|
triggerButton(id: string): void;
|
21
|
+
createInspector(): void;
|
22
|
+
clearInspector(): void;
|
23
23
|
}
|
package/types/core/types.d.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
export interface BroadcastData {
|
2
|
+
target: ApplicationMode;
|
2
3
|
event: EditorEvent;
|
3
|
-
data
|
4
|
+
data?: any;
|
4
5
|
}
|
5
|
-
export type ApplicationMode = '
|
6
|
+
export type ApplicationMode = 'app' | 'editor';
|
6
7
|
export type VoidCallback = () => void;
|
7
8
|
export type DataUpdateCallback = (data: any) => void;
|
8
|
-
export type EditorEvent = 'setSheet' | 'setSheetObject' | 'updateSheetObject' | 'updateTimeline' | 'addFolder' | 'bindObject' | 'updateBind' | 'addButton' | 'clickButton' | 'selectComponent' | 'draggableListUpdate';
|
9
|
+
export type EditorEvent = 'custom' | 'setSheet' | 'setSheetObject' | 'updateSheetObject' | 'updateTimeline' | 'getObject' | 'setObject' | 'updateObject' | 'getScene' | 'setScene' | 'createTexture' | 'requestMethod' | 'addFolder' | 'bindObject' | 'updateBind' | 'addButton' | 'clickButton' | 'selectComponent' | 'draggableListUpdate';
|
9
10
|
export type VoidFunc = () => void;
|
10
11
|
export type BroadcastCallback = (data: BroadcastData) => void;
|
11
12
|
export type TheatreUpdateCallback = (data: any) => void;
|
package/types/editor/Editor.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { CSSProperties, Ref } from 'react';
|
2
2
|
import './scss/index.scss';
|
3
3
|
type EditorProps = {
|
4
|
-
|
4
|
+
header?: JSX.Element | JSX.Element[];
|
5
5
|
children?: JSX.Element | JSX.Element[];
|
6
|
+
footer?: JSX.Element | JSX.Element[];
|
6
7
|
ref?: Ref<any>;
|
7
8
|
style?: CSSProperties;
|
8
9
|
};
|
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare const gridImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAABkCAYAAAA8AQ3AAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEoklEQVR4nO3aQc4aMRAFYR+AOQv3Px3ZRYoSoh8YxvX61YJdSdPuD++81lqPZ7/b7fa43++P4zieNnbPu+M40PO1dXqwujc9WIeY0nk5WJ0erO4DD84hpnReDlanB6v70INxiCmdl4PV6cHqTvDYf4gpnZeD1enB6k7yyDgsvfNysDo9WN2JHvzD0jsvB6vTg9Wd6kE/LL3zcrA6PVjd2R6LfFh65+VgdXqwum94LOph6Z2Xg9Xpweq+5bGIh6V3Xg5Wpwer+7IH67D0zsvB6vRgdRd4cA5L77wcrE4PVneRB+Ow9M7Lwer0YHUXeuw/LL3zcrA6PVjdxR4ZSynBsNMjqtvgwV9KEYadHjHdFg/6Uqow7PQI6XZ5+NIdhGGnR0K308OX7iAMOz3o3W6PRVxKK4adHuQO4sFaSjmGnR7IDuTBWYoYdnrwOpgHYyli2OnB64Ae+5cihp0evA7qkbG8EozaTg9WB/bgL68Io7LTg9WhPejLq8Io7PRgdXSPqpfudIy2Tg9Wl+BR89J9F0bCn6BpL3qw9vLqdxdxebuXkv5deqcHqwvzYC0PspTY79I7PVhdoAdneaClRH6X3unB6kI9GMuDLSXuu/ROD1YX7LF/ecClRH2X3unB6sI9MpZcgjGu04PVDfDgL7kIY1SnB6sb4UFfchXGoE4PVjfFY8RL9ykYUzo9WN0kj/iX7pMwJnR6sLppHou45N1LoX6X3unB6oZ6sJYMWQruu/ROD1Y32IOzZNBSUN+ld3qwuuEejCXTOy8Hq9OD1V3osf+w9M7Lwer0YHUXe2QspQTDTo+oboMHfylFGHZ6xHRbPOhLqcKw0yOk2+Ux4qX7FAw7PRK6nR7xL90nYdjpQe92eyziUlox7PQgdxAP1lLKMez0QHYgD85SxLDTg9fBPBhLEcNOD14H9Ni/FDHs9OB1UI+M5ZVg1HZ6sDqwB395RRiVnR6sDu1BX14VRmGnB6uje1S9dKdjtHV6sLoEj5qX7gkYTZ0erC7FY5GHa8No6fRgdWEe6OHaMMZ3erC6QA/0cG0Yozs9WF2oB3q4NoyxnR6sLtgDPVwbxshOD1YX7oEerg1jXKcHqxvggR6uDWNUpwerG+GBHq4NY1CnB6ub4jHipfsUjCmdHqxukkf8S/dJGBM6PVjdNI9FHq4NI73Tg9UN9UAP14YR2+nB6gZ7oIdrw4js9GB1wz3Qw7VhxHV6sLoCD/RwbRhRnR6srsQDPVwbRkynB6sr8kAP14YR0enB6qo80MO1YQR0erC6Ng/0S/c2DHqnB6tr9MC+dG/EIHd6sLpWj0UcrhWD2unB6so9WMOVY+A6PVidHqDhxGB1erA6PdZjUYYTg9Xpwer0+P3bP5wYrE4PVqfHHz8x7PSgdnr89RPDTg9ip8c/fmLY6cHr9HjyE8NOD1anx/Pu8pfuYrA6PVidHv/vlhi9nR6sTo8fdWI0dnqwOj1+3InR1unB6vR4qROjqdOD1enxcidGS6cHq9PjrU6Mhk4PVqfH250Y0zs9WJ0eH3RizO70YHV6fNad+tJdDFanB6vT4/PutJfuYrA6PVidHud0vwA7LKl1AiiR5gAAAABJRU5ErkJggg==";
|
2
|
+
export declare const noImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";
|
package/types/editor/global.d.ts
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
import { EventDispatcher } from 'three';
|
2
2
|
export declare const debugDispatcher: EventDispatcher<import("three").Event>;
|
3
3
|
export declare const ToolEvents: {
|
4
|
+
CUSTOM: string;
|
4
5
|
SELECT_DROPDOWN: string;
|
5
6
|
DRAG_UPDATE: string;
|
6
|
-
|
7
|
-
REFRESH_SCENE: string;
|
7
|
+
GET_SCENE: string;
|
8
8
|
SET_SCENE: string;
|
9
|
+
GET_OBJECT: string;
|
10
|
+
SET_OBJECT: string;
|
11
|
+
UPDATE_OBJECT: string;
|
12
|
+
CREATE_TEXTURE: string;
|
13
|
+
REQUEST_METHOD: string;
|
9
14
|
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
type AccordionProps = {
|
3
|
+
label: string;
|
4
|
+
button?: JSX.Element;
|
5
|
+
children?: JSX.Element | JSX.Element[];
|
6
|
+
open?: boolean;
|
7
|
+
onToggle?: (value: boolean) => void;
|
8
|
+
};
|
9
|
+
export default function Accordion(props: AccordionProps): import("react/jsx-runtime").JSX.Element;
|
10
|
+
export {};
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { Component, ReactNode } from 'react';
|
2
2
|
import '../scss/_sceneHierarchy.scss';
|
3
3
|
import { SceneHierarchyState } from './types';
|
4
|
-
export default class SceneHierarchy extends Component {
|
5
|
-
|
4
|
+
export default class SceneHierarchy extends Component<SceneHierarchyState> {
|
5
|
+
private three;
|
6
|
+
constructor(props: SceneHierarchyState);
|
7
|
+
componentDidMount(): void;
|
6
8
|
componentWillUnmount(): void;
|
7
9
|
render(): ReactNode;
|
8
|
-
private onUpdate;
|
9
|
-
private toggleOpen;
|
10
10
|
private onRefresh;
|
11
|
-
private
|
11
|
+
private setScene;
|
12
12
|
get componentState(): SceneHierarchyState;
|
13
13
|
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export type InspectorFieldType = 'string' | 'number' | 'boolean' | 'range' | 'color' | 'button' | 'image';
|
2
|
+
export interface InspectorFieldProps {
|
3
|
+
title: string;
|
4
|
+
type: InspectorFieldType;
|
5
|
+
prop?: string;
|
6
|
+
value?: any;
|
7
|
+
min?: number;
|
8
|
+
max?: number;
|
9
|
+
step?: number;
|
10
|
+
disabled?: boolean;
|
11
|
+
onChange?: (prop: string, value: any) => void;
|
12
|
+
}
|
13
|
+
export default function InspectorField(props: InspectorFieldProps): import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { InspectorFieldProps } from './InspectorField';
|
2
|
+
export interface InspectorGroupProps {
|
3
|
+
title: string;
|
4
|
+
expanded?: boolean;
|
5
|
+
items: InspectorFieldProps[] | InspectorGroupProps[];
|
6
|
+
}
|
7
|
+
export default function InspectorGroup(props: InspectorGroupProps): import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { Camera } from 'three';
|
3
|
+
interface DropdownProps {
|
4
|
+
index: number;
|
5
|
+
onSelect: (value: string) => void;
|
6
|
+
options: string[];
|
7
|
+
up?: boolean;
|
8
|
+
}
|
9
|
+
export declare const Dropdown: (props: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
10
|
+
interface CameraWindowProps {
|
11
|
+
camera: Camera;
|
12
|
+
onSelect: (value: string) => void;
|
13
|
+
options: string[];
|
14
|
+
}
|
15
|
+
declare const CameraWindow: import("react").ForwardRefExoticComponent<CameraWindowProps & import("react").RefAttributes<HTMLDivElement>>;
|
16
|
+
export default CameraWindow;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Color, ShaderMaterial } from 'three';
|
2
|
+
type InfiniteGridProps = {
|
3
|
+
divisions?: number;
|
4
|
+
scale?: number;
|
5
|
+
color?: Color;
|
6
|
+
distance?: number;
|
7
|
+
subgridOpacity?: number;
|
8
|
+
gridOpacity?: number;
|
9
|
+
};
|
10
|
+
export default class InfiniteGridMaterial extends ShaderMaterial {
|
11
|
+
constructor(props?: InfiniteGridProps);
|
12
|
+
}
|
13
|
+
export {};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Camera, Scene, WebGLRenderer } from 'three';
|
2
|
+
import './MultiView.scss';
|
3
|
+
type MultiViewMode = 'Single' | 'Side by Side' | 'Stacked' | 'Quad';
|
4
|
+
interface MultiViewProps {
|
5
|
+
scene: Scene;
|
6
|
+
renderer: WebGLRenderer;
|
7
|
+
cameras: Camera[];
|
8
|
+
mode?: MultiViewMode;
|
9
|
+
}
|
10
|
+
export default function MultiView(props: MultiViewProps): import("react/jsx-runtime").JSX.Element;
|
11
|
+
export {};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { RemoteMaterial, RemoteObject } from "../../types";
|
2
|
+
import RemoteThree from '@/core/remote/RemoteThree';
|
3
|
+
export declare function acceptedMaterialNames(name: string): boolean;
|
4
|
+
export declare function niceMaterialNames(name: string): string;
|
5
|
+
export declare function clampedNames(name: string): boolean;
|
6
|
+
export declare function uploadLocalImage(): Promise<string>;
|
7
|
+
export declare function inspectMaterialItems(material: RemoteMaterial, object: RemoteObject, three: RemoteThree): any[];
|
8
|
+
export declare function InspectMaterial(object: RemoteObject, three: RemoteThree): any;
|