@tomorrowevening/hermes 0.0.5 → 0.0.7
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/dist/hermes.js +314 -303
- package/dist/hermes.umd.cjs +12 -12
- package/package.json +6 -3
- package/src/editor/sceneHierarchy/ChildObject.tsx +1 -1
- package/src/editor/sceneHierarchy/inspector/Inspector.tsx +51 -38
- package/src/example/CustomEditor.tsx +0 -40
- package/src/example/components/App.css +0 -6
- package/src/example/components/App.tsx +0 -164
- package/src/example/constants.ts +0 -44
- package/src/example/index.scss +0 -37
- package/src/example/main.tsx +0 -35
- package/src/example/three/CustomMaterial.ts +0 -58
- package/src/example/three/ExampleScene.ts +0 -176
- package/src/example/three/FBXAnimation.ts +0 -39
- package/src/vite-env.d.ts +0 -1
- package/types/example/CustomEditor.d.ts +0 -1
- package/types/example/components/App.d.ts +0 -3
- package/types/example/constants.d.ts +0 -15
- package/types/example/main.d.ts +0 -1
- package/types/example/three/CustomMaterial.d.ts +0 -5
- package/types/example/three/ExampleScene.d.ts +0 -18
- package/types/example/three/FBXAnimation.d.ts +0 -6
@@ -1,164 +0,0 @@
|
|
1
|
-
// Libs
|
2
|
-
import { useEffect, useRef, useState } from 'react'
|
3
|
-
import { types } from '@theatre/core'
|
4
|
-
import { WebGLRenderer } from 'three';
|
5
|
-
// Models
|
6
|
-
import { app, IS_DEV } from '../constants'
|
7
|
-
// Components
|
8
|
-
import './App.css'
|
9
|
-
import ExampleScene from '../three/ExampleScene';
|
10
|
-
import SceneInspector from '@/editor/sceneHierarchy/inspector/SceneInspector';
|
11
|
-
import { debugDispatcher, ToolEvents } from '../../editor/global';
|
12
|
-
import MultiView from '@/editor/sceneHierarchy/inspector/MultiView/MultiView';
|
13
|
-
|
14
|
-
let renderer: WebGLRenderer;
|
15
|
-
let exampleScene: ExampleScene;
|
16
|
-
|
17
|
-
const useTweakpane = false;
|
18
|
-
const threeCameras: any[] = [];
|
19
|
-
|
20
|
-
function App() {
|
21
|
-
const elementRef = useRef<HTMLDivElement>(null!)
|
22
|
-
const [showSceneInspector, setShowSceneInspector] = useState(false);
|
23
|
-
app.theatre?.sheet('App')
|
24
|
-
|
25
|
-
// Theatre
|
26
|
-
useEffect(() => {
|
27
|
-
const container = elementRef.current!
|
28
|
-
container.style.visibility = app.editor ? 'hidden' : 'inherit'
|
29
|
-
|
30
|
-
// Theatre Example
|
31
|
-
const sheetObj = app.theatre?.sheetObject(
|
32
|
-
'App',
|
33
|
-
'Box',
|
34
|
-
{
|
35
|
-
x: types.number(100, {range: [0, window.innerWidth]}),
|
36
|
-
y: types.number(100, {range: [0, window.innerHeight]}),
|
37
|
-
},
|
38
|
-
(values: any) => {
|
39
|
-
container.style.left = `${values.x}px`
|
40
|
-
container.style.top = `${values.y}px`
|
41
|
-
},
|
42
|
-
)
|
43
|
-
return () => {
|
44
|
-
if (sheetObj !== undefined) app.theatre?.unsubscribe(sheetObj)
|
45
|
-
app.dispose()
|
46
|
-
}
|
47
|
-
}, [])
|
48
|
-
|
49
|
-
// ThreeJS
|
50
|
-
useEffect(() => {
|
51
|
-
renderer = new WebGLRenderer({ antialias: true });
|
52
|
-
renderer.autoClear = false;
|
53
|
-
renderer.shadowMap.enabled = true;
|
54
|
-
renderer.setPixelRatio(devicePixelRatio);
|
55
|
-
renderer.setClearColor(0x000000, 1);
|
56
|
-
elementRef.current.parentElement!.appendChild(renderer.domElement);
|
57
|
-
|
58
|
-
exampleScene = new ExampleScene();
|
59
|
-
threeCameras.push(exampleScene.camera);
|
60
|
-
|
61
|
-
// Start RAF
|
62
|
-
let raf = -1;
|
63
|
-
|
64
|
-
const onResize = () => {
|
65
|
-
let width = window.innerWidth;
|
66
|
-
const height = window.innerHeight;
|
67
|
-
if (app.editor) width -= 300;
|
68
|
-
renderer.setSize(width, height);
|
69
|
-
exampleScene.resize(width, height);
|
70
|
-
};
|
71
|
-
|
72
|
-
const onUpdate = () => {
|
73
|
-
renderer.clear();
|
74
|
-
exampleScene.update();
|
75
|
-
renderer.render(exampleScene, exampleScene.camera);
|
76
|
-
raf = requestAnimationFrame(onUpdate);
|
77
|
-
};
|
78
|
-
|
79
|
-
app.three.setScene(exampleScene);
|
80
|
-
onResize();
|
81
|
-
window.addEventListener('resize', onResize);
|
82
|
-
if (!app.editor) onUpdate();
|
83
|
-
setShowSceneInspector(true);
|
84
|
-
|
85
|
-
return () => {
|
86
|
-
window.removeEventListener('resize', onResize);
|
87
|
-
renderer.dispose();
|
88
|
-
cancelAnimationFrame(raf);
|
89
|
-
raf = -1;
|
90
|
-
}
|
91
|
-
}, [])
|
92
|
-
|
93
|
-
// Debug Components
|
94
|
-
if (IS_DEV) {
|
95
|
-
useEffect(() => {
|
96
|
-
const container = elementRef.current!;
|
97
|
-
container.style.visibility = app.editor ? 'hidden' : 'inherit';
|
98
|
-
|
99
|
-
// Tweakpane Example
|
100
|
-
if (useTweakpane) {
|
101
|
-
const testFolder = app.debug.addFolder('Test Folder');
|
102
|
-
|
103
|
-
app.debug.button('Test Button', () => {
|
104
|
-
console.log('Test button works!');
|
105
|
-
}, testFolder);
|
106
|
-
|
107
|
-
const test = { opacity: 1, rotation: 0 };
|
108
|
-
app.debug.bind(test, 'opacity', {
|
109
|
-
min: 0,
|
110
|
-
max: 1,
|
111
|
-
onChange: (value: number) => {
|
112
|
-
container.style.opacity = value.toFixed(2);
|
113
|
-
}
|
114
|
-
}, testFolder);
|
115
|
-
|
116
|
-
app.debug.bind(test, 'rotation', {
|
117
|
-
min: 0,
|
118
|
-
max: 360,
|
119
|
-
onChange: (value: number) => {
|
120
|
-
container.style.transform = `rotate(${value}deg)`;
|
121
|
-
}
|
122
|
-
}, testFolder);
|
123
|
-
}
|
124
|
-
|
125
|
-
// Components Example
|
126
|
-
const onCustom = (evt: any) => {
|
127
|
-
console.log('Custom:', evt.value)
|
128
|
-
}
|
129
|
-
const selectDropdown = (evt: any) => {
|
130
|
-
console.log(`Dropdown: ${evt.value.dropdown}, value: ${evt.value.value}`)
|
131
|
-
}
|
132
|
-
debugDispatcher.addEventListener(ToolEvents.CUSTOM, onCustom)
|
133
|
-
debugDispatcher.addEventListener(ToolEvents.SELECT_DROPDOWN, selectDropdown)
|
134
|
-
return () => {
|
135
|
-
debugDispatcher.removeEventListener(ToolEvents.CUSTOM, onCustom)
|
136
|
-
debugDispatcher.removeEventListener(ToolEvents.SELECT_DROPDOWN, selectDropdown)
|
137
|
-
}
|
138
|
-
}, [])
|
139
|
-
}
|
140
|
-
|
141
|
-
return (
|
142
|
-
<>
|
143
|
-
<div id='box' ref={elementRef}>
|
144
|
-
<button onClick={() => {
|
145
|
-
app.send({
|
146
|
-
target: 'editor',
|
147
|
-
event: 'custom',
|
148
|
-
data: 'hello editor!'
|
149
|
-
});
|
150
|
-
}}>Click</button>
|
151
|
-
</div>
|
152
|
-
|
153
|
-
{IS_DEV && showSceneInspector && (
|
154
|
-
<SceneInspector scene={exampleScene} three={app.three} />
|
155
|
-
)}
|
156
|
-
|
157
|
-
{IS_DEV && showSceneInspector && app.editor && (
|
158
|
-
<MultiView scene={exampleScene} renderer={renderer} cameras={threeCameras} />
|
159
|
-
)}
|
160
|
-
</>
|
161
|
-
)
|
162
|
-
}
|
163
|
-
|
164
|
-
export default App
|
package/src/example/constants.ts
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
import Application from '@/core/Application'
|
2
|
-
import RemoteComponents from '@/core/remote/RemoteComponents'
|
3
|
-
import RemoteTheatre from '@/core/remote/RemoteTheatre'
|
4
|
-
import RemoteThree from '@/core/remote/RemoteThree'
|
5
|
-
import RemoteTweakpane from '@/core/remote/RemoteTweakpane'
|
6
|
-
|
7
|
-
export const IS_DEV = true
|
8
|
-
// export const IS_DEV = import.meta.env.DEV
|
9
|
-
// export const app = new Application('Hermes', IS_DEV, 'editor')
|
10
|
-
|
11
|
-
class CustomApp extends Application {
|
12
|
-
constructor(name: string, debugEnabled: boolean, editorHashtag: string) {
|
13
|
-
super(name, debugEnabled, editorHashtag)
|
14
|
-
|
15
|
-
// Add components
|
16
|
-
this.addComponent('theatre', new RemoteTheatre(this, 'RemoteApp', {}))
|
17
|
-
|
18
|
-
if (IS_DEV) {
|
19
|
-
this.addComponent('components', new RemoteComponents(this))
|
20
|
-
// this.addComponent('debug', new RemoteTweakpane(this))
|
21
|
-
this.addComponent('three', new RemoteThree(this))
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
// Components
|
26
|
-
|
27
|
-
get debug(): RemoteTweakpane {
|
28
|
-
return this.components.get('debug') as RemoteTweakpane
|
29
|
-
}
|
30
|
-
|
31
|
-
get debugComponents(): RemoteComponents {
|
32
|
-
return this.components.get('components') as RemoteComponents
|
33
|
-
}
|
34
|
-
|
35
|
-
get theatre(): RemoteTheatre {
|
36
|
-
return this.components.get('theatre') as RemoteTheatre
|
37
|
-
}
|
38
|
-
|
39
|
-
get three(): RemoteThree {
|
40
|
-
return this.components.get('three') as RemoteThree
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
export const app = new CustomApp('Hermes', IS_DEV, 'editor')
|
package/src/example/index.scss
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
:root {
|
2
|
-
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
3
|
-
line-height: 1.5;
|
4
|
-
font-weight: 400;
|
5
|
-
|
6
|
-
color-scheme: light dark;
|
7
|
-
color: rgba(255, 255, 255, 0.87);
|
8
|
-
background-color: #242424;
|
9
|
-
|
10
|
-
font-synthesis: none;
|
11
|
-
text-rendering: optimizeLegibility;
|
12
|
-
-webkit-font-smoothing: antialiased;
|
13
|
-
-moz-osx-font-smoothing: grayscale;
|
14
|
-
-webkit-text-size-adjust: 100%;
|
15
|
-
}
|
16
|
-
|
17
|
-
html, body {
|
18
|
-
min-width: 100%;
|
19
|
-
min-height: 100%;
|
20
|
-
width: 100%;
|
21
|
-
height: 100%;
|
22
|
-
}
|
23
|
-
|
24
|
-
body {
|
25
|
-
padding: 0;
|
26
|
-
margin: 0;
|
27
|
-
}
|
28
|
-
|
29
|
-
button {
|
30
|
-
&:focus {
|
31
|
-
outline: none;
|
32
|
-
}
|
33
|
-
|
34
|
-
&:hover {
|
35
|
-
cursor: pointer;
|
36
|
-
}
|
37
|
-
}
|
package/src/example/main.tsx
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
// Libs
|
2
|
-
import React from 'react'
|
3
|
-
import ReactDOM from 'react-dom/client'
|
4
|
-
import studio from '@theatre/studio'
|
5
|
-
// Models
|
6
|
-
import { app, IS_DEV } from './constants'
|
7
|
-
// Components
|
8
|
-
import './index.scss'
|
9
|
-
import App from './components/App'
|
10
|
-
import CustomEditor from './CustomEditor'
|
11
|
-
// Tools
|
12
|
-
import RemoteController from '@/core/RemoteController'
|
13
|
-
|
14
|
-
// Debug tools
|
15
|
-
if (IS_DEV) {
|
16
|
-
studio.initialize()
|
17
|
-
RemoteController(app)
|
18
|
-
}
|
19
|
-
|
20
|
-
// React
|
21
|
-
|
22
|
-
ReactDOM.createRoot(document.getElementById('root')!).render(
|
23
|
-
<>
|
24
|
-
{IS_DEV ? (
|
25
|
-
<>
|
26
|
-
<App />
|
27
|
-
{app.editor ? <CustomEditor /> : null}
|
28
|
-
</>
|
29
|
-
) : (
|
30
|
-
<React.StrictMode>
|
31
|
-
<App />
|
32
|
-
</React.StrictMode>
|
33
|
-
)}
|
34
|
-
</>,
|
35
|
-
)
|
@@ -1,58 +0,0 @@
|
|
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
|
-
}
|
@@ -1,176 +0,0 @@
|
|
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
|
-
}
|
@@ -1,39 +0,0 @@
|
|
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/vite-env.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
/// <reference types="vite/client" />
|
@@ -1 +0,0 @@
|
|
1
|
-
export default function CustomEditor(): import("react/jsx-runtime").JSX.Element;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import Application from '@/core/Application';
|
2
|
-
import RemoteComponents from '@/core/remote/RemoteComponents';
|
3
|
-
import RemoteTheatre from '@/core/remote/RemoteTheatre';
|
4
|
-
import RemoteThree from '@/core/remote/RemoteThree';
|
5
|
-
import RemoteTweakpane from '@/core/remote/RemoteTweakpane';
|
6
|
-
export declare const IS_DEV = true;
|
7
|
-
declare class CustomApp extends Application {
|
8
|
-
constructor(name: string, debugEnabled: boolean, editorHashtag: string);
|
9
|
-
get debug(): RemoteTweakpane;
|
10
|
-
get debugComponents(): RemoteComponents;
|
11
|
-
get theatre(): RemoteTheatre;
|
12
|
-
get three(): RemoteThree;
|
13
|
-
}
|
14
|
-
export declare const app: CustomApp;
|
15
|
-
export {};
|
package/types/example/main.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import './index.scss';
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { CubeTexture, PerspectiveCamera, Scene } from 'three';
|
2
|
-
import FBXAnimation from './FBXAnimation';
|
3
|
-
export default class ExampleScene extends Scene {
|
4
|
-
camera: PerspectiveCamera;
|
5
|
-
envMap: CubeTexture;
|
6
|
-
dance0: FBXAnimation;
|
7
|
-
dance1: FBXAnimation;
|
8
|
-
dance2: FBXAnimation;
|
9
|
-
private customMat;
|
10
|
-
private lastUpdate;
|
11
|
-
constructor();
|
12
|
-
private createCameras;
|
13
|
-
private createLights;
|
14
|
-
private createWorld;
|
15
|
-
private createTestMaterials;
|
16
|
-
resize(width: number, height: number): void;
|
17
|
-
update(): void;
|
18
|
-
}
|