@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,124 @@
|
|
1
|
+
import { Euler, Matrix4, Vector3 } from 'three';
|
2
|
+
import InspectorGroup from '../InspectorGroup';
|
3
|
+
import { RemoteObject } from "../../types";
|
4
|
+
import RemoteThree from '@/core/remote/RemoteThree';
|
5
|
+
import { setItemProps } from '../../utils';
|
6
|
+
|
7
|
+
export function InspectTransform(obj: RemoteObject, three: RemoteThree) {
|
8
|
+
const matrix = new Matrix4();
|
9
|
+
matrix.elements = obj.matrix;
|
10
|
+
const position = new Vector3();
|
11
|
+
const rotation = new Euler();
|
12
|
+
const scale = new Vector3();
|
13
|
+
if (obj.uuid.length > 0) {
|
14
|
+
position.setFromMatrixPosition(matrix);
|
15
|
+
rotation.setFromRotationMatrix(matrix);
|
16
|
+
scale.setFromMatrixScale(matrix);
|
17
|
+
}
|
18
|
+
|
19
|
+
const updateTransform = (prop: string, value: any) => {
|
20
|
+
three.updateObject(obj.uuid, prop, value);
|
21
|
+
const child = three.scene?.getObjectByProperty('uuid', obj.uuid);
|
22
|
+
if (child !== undefined) setItemProps(child, prop, value);
|
23
|
+
};
|
24
|
+
|
25
|
+
const items: any[] = [
|
26
|
+
{
|
27
|
+
title: 'Position',
|
28
|
+
items: [
|
29
|
+
{
|
30
|
+
title: 'X',
|
31
|
+
prop: 'position.x',
|
32
|
+
type: 'number',
|
33
|
+
value: position.x,
|
34
|
+
onChange: updateTransform,
|
35
|
+
},
|
36
|
+
{
|
37
|
+
title: 'Y',
|
38
|
+
prop: 'position.y',
|
39
|
+
type: 'number',
|
40
|
+
value: position.y,
|
41
|
+
onChange: updateTransform,
|
42
|
+
},
|
43
|
+
{
|
44
|
+
title: 'Z',
|
45
|
+
prop: 'position.z',
|
46
|
+
type: 'number',
|
47
|
+
value: position.z,
|
48
|
+
onChange: updateTransform,
|
49
|
+
},
|
50
|
+
],
|
51
|
+
},
|
52
|
+
{
|
53
|
+
title: 'Rotation',
|
54
|
+
items: [
|
55
|
+
{
|
56
|
+
title: 'X',
|
57
|
+
prop: 'rotation.x',
|
58
|
+
type: 'number',
|
59
|
+
value: rotation.x,
|
60
|
+
min: -Math.PI,
|
61
|
+
max: Math.PI,
|
62
|
+
step: 0.01,
|
63
|
+
onChange: updateTransform,
|
64
|
+
},
|
65
|
+
{
|
66
|
+
title: 'Y',
|
67
|
+
prop: 'rotation.y',
|
68
|
+
type: 'number',
|
69
|
+
value: rotation.y,
|
70
|
+
min: -Math.PI,
|
71
|
+
max: Math.PI,
|
72
|
+
step: 0.01,
|
73
|
+
onChange: updateTransform,
|
74
|
+
},
|
75
|
+
{
|
76
|
+
title: 'Z',
|
77
|
+
prop: 'rotation.z',
|
78
|
+
type: 'number',
|
79
|
+
value: rotation.z,
|
80
|
+
min: -Math.PI,
|
81
|
+
max: Math.PI,
|
82
|
+
step: 0.01,
|
83
|
+
onChange: updateTransform,
|
84
|
+
},
|
85
|
+
],
|
86
|
+
},
|
87
|
+
{
|
88
|
+
title: 'Scale',
|
89
|
+
items: [
|
90
|
+
{
|
91
|
+
title: 'X',
|
92
|
+
prop: 'scale.x',
|
93
|
+
type: 'number',
|
94
|
+
value: scale.x,
|
95
|
+
step: 0.01,
|
96
|
+
onChange: updateTransform,
|
97
|
+
},
|
98
|
+
{
|
99
|
+
title: 'Y',
|
100
|
+
prop: 'scale.y',
|
101
|
+
type: 'number',
|
102
|
+
value: scale.y,
|
103
|
+
step: 0.01,
|
104
|
+
onChange: updateTransform,
|
105
|
+
},
|
106
|
+
{
|
107
|
+
title: 'Z',
|
108
|
+
prop: 'scale.z',
|
109
|
+
type: 'number',
|
110
|
+
value: scale.z,
|
111
|
+
step: 0.01,
|
112
|
+
onChange: updateTransform,
|
113
|
+
},
|
114
|
+
],
|
115
|
+
},
|
116
|
+
];
|
117
|
+
|
118
|
+
return (
|
119
|
+
<InspectorGroup
|
120
|
+
title="Transform"
|
121
|
+
items={items}
|
122
|
+
/>
|
123
|
+
);
|
124
|
+
}
|
@@ -1,10 +1,121 @@
|
|
1
|
-
import
|
1
|
+
import RemoteThree from '@/core/remote/RemoteThree';
|
2
|
+
import { Color, Object3D } from 'three';
|
2
3
|
|
3
|
-
export
|
4
|
+
export interface CoreComponentProps {
|
5
|
+
class?: string
|
6
|
+
three: RemoteThree
|
7
|
+
}
|
8
|
+
|
9
|
+
export interface ChildObjectProps extends CoreComponentProps {
|
4
10
|
child: Object3D
|
11
|
+
three: RemoteThree
|
12
|
+
}
|
13
|
+
|
14
|
+
export interface SceneHierarchyState {
|
15
|
+
scene?: Object3D
|
16
|
+
three: RemoteThree
|
17
|
+
}
|
18
|
+
|
19
|
+
export interface MinimumObject {
|
20
|
+
name: string
|
21
|
+
uuid: string
|
22
|
+
type: string
|
23
|
+
children: MinimumObject[]
|
24
|
+
}
|
25
|
+
|
26
|
+
export interface RemoteMaterial {
|
27
|
+
// Blending
|
28
|
+
blending: number
|
29
|
+
blendSrc: number
|
30
|
+
blendDst: number
|
31
|
+
blendEquation: number
|
32
|
+
blendColor: Color
|
33
|
+
blendAlpha: number
|
34
|
+
// Depth
|
35
|
+
depthFunc: number
|
36
|
+
depthTest: boolean
|
37
|
+
depthWrite: boolean
|
38
|
+
// Stencil
|
39
|
+
stencilWriteMask: number
|
40
|
+
stencilFunc: number
|
41
|
+
stencilRef: number
|
42
|
+
stencilFuncMask: number
|
43
|
+
stencilFail: number
|
44
|
+
stencilZFail: number
|
45
|
+
stencilZPass: number
|
46
|
+
stencilWrite: boolean
|
47
|
+
// Clipping
|
48
|
+
clipIntersection: boolean
|
49
|
+
// Polygon
|
50
|
+
polygonOffset: boolean
|
51
|
+
polygonOffsetFactor: number
|
52
|
+
polygonOffsetUnits: number
|
53
|
+
// ETC
|
54
|
+
dithering: boolean
|
55
|
+
name: string
|
56
|
+
opacity: number
|
57
|
+
premultipliedAlpha: boolean
|
58
|
+
side: number
|
59
|
+
toneMapped: boolean
|
60
|
+
transparent: boolean
|
61
|
+
type: string
|
62
|
+
uuid: string
|
63
|
+
vertexColors: boolean
|
64
|
+
defines: any
|
65
|
+
extensions: any
|
66
|
+
uniforms: any
|
67
|
+
// Colors
|
68
|
+
color?: Color
|
69
|
+
attenuationColor?: Color
|
70
|
+
sheenColor?: Color
|
71
|
+
specularColor?: Color
|
72
|
+
}
|
73
|
+
|
74
|
+
// Camera Info
|
75
|
+
|
76
|
+
export interface PerspectiveCameraInfo {
|
77
|
+
fov: number
|
78
|
+
zoom: number
|
79
|
+
near: number
|
80
|
+
far: number
|
81
|
+
focus: number
|
82
|
+
aspect: number
|
83
|
+
filmGauge: number
|
84
|
+
filmOffset: number
|
85
|
+
}
|
86
|
+
|
87
|
+
export interface OrthographicCameraInfo {
|
88
|
+
zoom: number
|
89
|
+
near: number
|
90
|
+
far: number
|
91
|
+
left: number
|
92
|
+
right: number
|
93
|
+
top: number
|
94
|
+
bottom: number
|
95
|
+
}
|
96
|
+
|
97
|
+
// Light Info
|
98
|
+
export interface LightInfo {
|
99
|
+
color: Color
|
100
|
+
intensity: number
|
101
|
+
// Point
|
102
|
+
decay?: number
|
103
|
+
distance?: number
|
104
|
+
// Spot
|
105
|
+
angle?: number
|
106
|
+
penumbra?: number
|
107
|
+
// Hemisphere
|
108
|
+
groundColor?: Color
|
5
109
|
}
|
6
110
|
|
7
|
-
export
|
8
|
-
|
9
|
-
|
111
|
+
export interface RemoteObject {
|
112
|
+
name: string
|
113
|
+
uuid: string
|
114
|
+
type: string
|
115
|
+
visible: boolean
|
116
|
+
matrix: number[] // based on Matrix4.elements
|
117
|
+
material?: RemoteMaterial | RemoteMaterial[]
|
118
|
+
perspectiveCameraInfo?: PerspectiveCameraInfo
|
119
|
+
orthographicCameraInfo?: OrthographicCameraInfo
|
120
|
+
lightInfo?: LightInfo
|
10
121
|
}
|
@@ -1,25 +1,221 @@
|
|
1
|
-
import { Object3D } from 'three'
|
1
|
+
import { Camera, CubeTexture, Light, Material, Mesh, Object3D, OrthographicCamera, PerspectiveCamera, RepeatWrapping, Texture } from 'three';
|
2
|
+
import { MinimumObject, RemoteMaterial, RemoteObject } from './types';
|
2
3
|
|
3
4
|
export function determineIcon(obj: Object3D): string {
|
4
5
|
if (obj.name === 'cameras') {
|
5
|
-
return 'camera'
|
6
|
+
return 'camera';
|
6
7
|
} else if (obj.name === 'interactive') {
|
7
|
-
return 'interactive'
|
8
|
+
return 'interactive';
|
8
9
|
} else if (obj.name === 'lights') {
|
9
|
-
return 'light'
|
10
|
+
return 'light';
|
10
11
|
} else if (obj.name === 'ui') {
|
11
|
-
return 'ui'
|
12
|
+
return 'ui';
|
12
13
|
} else if (obj.name === 'utils') {
|
13
|
-
return 'utils'
|
14
|
+
return 'utils';
|
14
15
|
}
|
15
16
|
|
16
|
-
const type = obj.type
|
17
|
+
const type = obj.type;
|
17
18
|
if (type.search('Helper') > -1) {
|
18
|
-
return 'icon_utils'
|
19
|
+
return 'icon_utils';
|
19
20
|
} else if (type.search('Camera') > -1) {
|
20
|
-
return 'camera'
|
21
|
+
return 'camera';
|
21
22
|
} else if (type.search('Light') > -1) {
|
22
|
-
return 'light'
|
23
|
+
return 'light';
|
23
24
|
}
|
24
|
-
return 'obj3D'
|
25
|
+
return 'obj3D';
|
26
|
+
}
|
27
|
+
|
28
|
+
export function stripScene(obj: Object3D): MinimumObject {
|
29
|
+
const min: MinimumObject = {
|
30
|
+
name: obj.name,
|
31
|
+
type: obj.type,
|
32
|
+
uuid: obj.uuid,
|
33
|
+
children: [],
|
34
|
+
};
|
35
|
+
obj.children.forEach((child: Object3D) => {
|
36
|
+
min.children.push(stripScene(child));
|
37
|
+
});
|
38
|
+
return min;
|
39
|
+
}
|
40
|
+
|
41
|
+
function cleanUniforms(obj: any) {
|
42
|
+
const newObj = {};
|
43
|
+
for (const i in obj) {
|
44
|
+
const value = obj[i].value;
|
45
|
+
newObj[i] = { value: value };
|
46
|
+
if (value === null) {
|
47
|
+
newObj[i].value = { src: '' };
|
48
|
+
} else if (value.isTexture) {
|
49
|
+
newObj[i].value = { src: value.image.src };
|
50
|
+
}
|
51
|
+
}
|
52
|
+
return newObj;
|
53
|
+
}
|
54
|
+
|
55
|
+
function skipPropertyName(value: string): boolean {
|
56
|
+
switch (value) {
|
57
|
+
case 'blendSrcAlpha':
|
58
|
+
case 'blendDstAlpha':
|
59
|
+
case 'blendEquationAlpha':
|
60
|
+
case 'clippingPlanes':
|
61
|
+
case 'shadowSide':
|
62
|
+
case 'precision':
|
63
|
+
return true;
|
64
|
+
}
|
65
|
+
return false;
|
66
|
+
}
|
67
|
+
|
68
|
+
function stripMaterialData(material: Material): RemoteMaterial {
|
69
|
+
const materialData = {};
|
70
|
+
for (const i in material) {
|
71
|
+
if (i.substring(0, 1) === '_' || i.substring(0, 2) === 'is') continue;
|
72
|
+
if (skipPropertyName(i)) continue;
|
73
|
+
|
74
|
+
const type = typeof material[i];
|
75
|
+
const value = material[i];
|
76
|
+
switch (type) {
|
77
|
+
case 'boolean':
|
78
|
+
case 'number':
|
79
|
+
case 'string':
|
80
|
+
materialData[i] = value;
|
81
|
+
break;
|
82
|
+
case 'object':
|
83
|
+
if (value !== null) {
|
84
|
+
materialData[i] = value;
|
85
|
+
if (value.isTexture) {
|
86
|
+
if (value instanceof Texture) {
|
87
|
+
// materialData[i] = { src: convertImageToBase64(value.image) };
|
88
|
+
const textureSource = value.source.toJSON();
|
89
|
+
// @ts-ignore
|
90
|
+
materialData[i] = { src: textureSource.url };
|
91
|
+
} else if (value instanceof CubeTexture) {
|
92
|
+
console.log('env map');
|
93
|
+
console.log(value.source.data);
|
94
|
+
console.log(value.source.toJSON());
|
95
|
+
materialData[i] = { src: '' };
|
96
|
+
}
|
97
|
+
} else if (i === 'uniforms') {
|
98
|
+
materialData[i] = cleanUniforms(materialData[i]);
|
99
|
+
}
|
100
|
+
} else {
|
101
|
+
materialData[i] = { src: '' };
|
102
|
+
}
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
return materialData as RemoteMaterial;
|
108
|
+
}
|
109
|
+
|
110
|
+
export function convertImageToBase64(imgElement: HTMLImageElement): string {
|
111
|
+
// Create a canvas element
|
112
|
+
const canvas = document.createElement('canvas');
|
113
|
+
const ctx = canvas.getContext('2d');
|
114
|
+
|
115
|
+
// Set the canvas dimensions to match the image
|
116
|
+
canvas.width = imgElement.width;
|
117
|
+
canvas.height = imgElement.height;
|
118
|
+
|
119
|
+
// Draw the image onto the canvas
|
120
|
+
ctx!.drawImage(imgElement, 0, 0);
|
121
|
+
|
122
|
+
// Get the Base64 representation of the image from the canvas
|
123
|
+
return canvas.toDataURL('image/png');
|
124
|
+
}
|
125
|
+
|
126
|
+
export function stripObject(obj: Object3D): RemoteObject {
|
127
|
+
obj.updateMatrix();
|
128
|
+
|
129
|
+
const stripped: RemoteObject = {
|
130
|
+
name: obj.name,
|
131
|
+
type: obj.type,
|
132
|
+
uuid: obj.uuid,
|
133
|
+
visible: obj.visible,
|
134
|
+
matrix: obj.matrix.elements,
|
135
|
+
};
|
136
|
+
|
137
|
+
if (obj instanceof Mesh) {
|
138
|
+
const mesh = obj as Mesh;
|
139
|
+
if (Array.isArray(mesh.material)) {
|
140
|
+
const data: RemoteMaterial[] = [];
|
141
|
+
mesh.material.forEach((material: Material) => {
|
142
|
+
data.push(stripMaterialData(material));
|
143
|
+
});
|
144
|
+
stripped.material = data;
|
145
|
+
} else {
|
146
|
+
stripped.material = stripMaterialData(mesh.material);
|
147
|
+
}
|
148
|
+
} else if (obj instanceof Camera) {
|
149
|
+
if (obj instanceof PerspectiveCamera) {
|
150
|
+
stripped.perspectiveCameraInfo = {
|
151
|
+
fov: obj.fov,
|
152
|
+
zoom: obj.zoom,
|
153
|
+
near: obj.near,
|
154
|
+
far: obj.far,
|
155
|
+
focus: obj.focus,
|
156
|
+
aspect: obj.aspect,
|
157
|
+
filmGauge: obj.filmGauge,
|
158
|
+
filmOffset: obj.filmOffset,
|
159
|
+
};
|
160
|
+
} else if (obj instanceof OrthographicCamera) {
|
161
|
+
stripped.orthographicCameraInfo = {
|
162
|
+
zoom: obj.zoom,
|
163
|
+
near: obj.near,
|
164
|
+
far: obj.far,
|
165
|
+
left: obj.left,
|
166
|
+
right: obj.right,
|
167
|
+
top: obj.top,
|
168
|
+
bottom: obj.bottom,
|
169
|
+
};
|
170
|
+
}
|
171
|
+
} else if (obj instanceof Light) {
|
172
|
+
stripped.lightInfo = {
|
173
|
+
color: obj.color,
|
174
|
+
intensity: obj.intensity,
|
175
|
+
decay: obj['decay'],
|
176
|
+
distance: obj['distance'],
|
177
|
+
angle: obj['angle'],
|
178
|
+
penumbra: obj['penumbra'],
|
179
|
+
groundColor: obj['groundColor'],
|
180
|
+
};
|
181
|
+
}
|
182
|
+
|
183
|
+
return stripped;
|
184
|
+
}
|
185
|
+
|
186
|
+
export function setItemProps(child: any, key: string, value: any) {
|
187
|
+
const keys = key.split('.');
|
188
|
+
const total = keys.length;
|
189
|
+
switch (total) {
|
190
|
+
case 1:
|
191
|
+
child[keys[0]] = value;
|
192
|
+
break;
|
193
|
+
case 2:
|
194
|
+
child[keys[0]][keys[1]] = value;
|
195
|
+
break;
|
196
|
+
case 3:
|
197
|
+
child[keys[0]][keys[1]][keys[2]] = value;
|
198
|
+
break;
|
199
|
+
case 4:
|
200
|
+
child[keys[0]][keys[1]][keys[2]][keys[3]] = value;
|
201
|
+
break;
|
202
|
+
case 5:
|
203
|
+
child[keys[0]][keys[1]][keys[2]][keys[3]][keys[4]] = value;
|
204
|
+
break;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
export function textureFromSrc(imgSource: string): Promise<Texture> {
|
209
|
+
return new Promise((resolve, reject) => {
|
210
|
+
const img = new Image();
|
211
|
+
img.onload = () => {
|
212
|
+
const texture = new Texture(img);
|
213
|
+
texture.wrapS = RepeatWrapping;
|
214
|
+
texture.wrapT = RepeatWrapping;
|
215
|
+
texture.needsUpdate = true;
|
216
|
+
resolve(texture);
|
217
|
+
};
|
218
|
+
img.onerror = reject;
|
219
|
+
img.src = imgSource;
|
220
|
+
});
|
25
221
|
}
|
@@ -1,7 +1,4 @@
|
|
1
|
-
$maxInput: 160px;
|
2
|
-
|
3
1
|
body {
|
4
|
-
|
5
2
|
.tp-dfwv,
|
6
3
|
.tp-dfwv button,
|
7
4
|
.tp-dfwv input {
|
@@ -14,38 +11,31 @@ body {
|
|
14
11
|
}
|
15
12
|
|
16
13
|
.tp-dfwv {
|
14
|
+
left: 50%;
|
15
|
+
top: 0;
|
16
|
+
max-height: 100%;
|
17
|
+
overflow-x: hidden;
|
18
|
+
overflow-y: auto;
|
19
|
+
transform: translateX(-50%);
|
20
|
+
width: 400px;
|
21
|
+
z-index: 100;
|
22
|
+
|
17
23
|
.tp-lblv {
|
18
24
|
position: relative;
|
19
25
|
}
|
20
26
|
|
21
27
|
.tp-lblv_v {
|
22
28
|
display: inline-block;
|
23
|
-
max-width: $maxInput;
|
24
29
|
|
25
30
|
.tp-ckbv {
|
26
31
|
width: 20px;
|
27
32
|
}
|
28
33
|
|
29
|
-
.tp-txtv,
|
30
|
-
.tp-sldtxtv {
|
31
|
-
max-width: $maxInput;
|
32
|
-
}
|
33
|
-
|
34
|
-
.tp-lstv {
|
35
|
-
width: $maxInput;
|
36
|
-
}
|
37
|
-
|
38
34
|
.tp-fpsv {
|
39
35
|
width: 280px;
|
40
36
|
}
|
41
37
|
}
|
42
38
|
|
43
|
-
.tp-lblv-nol {
|
44
|
-
.tp-btnv {
|
45
|
-
width: 280px;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
39
|
.tp-btnv_b {
|
50
40
|
padding: 0 5px;
|
51
41
|
}
|