@thanhthbm/scene-editor 0.1.0
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 +169 -0
- package/dist/index.css +921 -0
- package/dist/index.js +14076 -0
- package/package.json +49 -0
- package/src/editor/css/main.css +1030 -0
- package/src/editor/js/Animation.js +618 -0
- package/src/editor/js/AnimationResizer.js +73 -0
- package/src/editor/js/Command.js +40 -0
- package/src/editor/js/Config.js +86 -0
- package/src/editor/js/Editor.js +1006 -0
- package/src/editor/js/EditorControls.js +489 -0
- package/src/editor/js/GLTFImportDialog.js +112 -0
- package/src/editor/js/History.js +321 -0
- package/src/editor/js/Loader.js +1162 -0
- package/src/editor/js/LoaderUtils.js +90 -0
- package/src/editor/js/Menubar.Add.js +559 -0
- package/src/editor/js/Menubar.Edit.js +155 -0
- package/src/editor/js/Menubar.File.js +585 -0
- package/src/editor/js/Menubar.Help.js +73 -0
- package/src/editor/js/Menubar.Render.js +858 -0
- package/src/editor/js/Menubar.Status.js +51 -0
- package/src/editor/js/Menubar.View.js +193 -0
- package/src/editor/js/Menubar.js +29 -0
- package/src/editor/js/Player.js +53 -0
- package/src/editor/js/Resizer.js +65 -0
- package/src/editor/js/Script.js +532 -0
- package/src/editor/js/Selector.js +129 -0
- package/src/editor/js/Sidebar.Geometry.BoxGeometry.js +121 -0
- package/src/editor/js/Sidebar.Geometry.BufferGeometry.js +124 -0
- package/src/editor/js/Sidebar.Geometry.CapsuleGeometry.js +109 -0
- package/src/editor/js/Sidebar.Geometry.CircleGeometry.js +97 -0
- package/src/editor/js/Sidebar.Geometry.CylinderGeometry.js +121 -0
- package/src/editor/js/Sidebar.Geometry.DodecahedronGeometry.js +73 -0
- package/src/editor/js/Sidebar.Geometry.ExtrudeGeometry.js +196 -0
- package/src/editor/js/Sidebar.Geometry.IcosahedronGeometry.js +73 -0
- package/src/editor/js/Sidebar.Geometry.LatheGeometry.js +98 -0
- package/src/editor/js/Sidebar.Geometry.Modifiers.js +73 -0
- package/src/editor/js/Sidebar.Geometry.OctahedronGeometry.js +74 -0
- package/src/editor/js/Sidebar.Geometry.PlaneGeometry.js +97 -0
- package/src/editor/js/Sidebar.Geometry.RingGeometry.js +121 -0
- package/src/editor/js/Sidebar.Geometry.ShapeGeometry.js +76 -0
- package/src/editor/js/Sidebar.Geometry.SphereGeometry.js +133 -0
- package/src/editor/js/Sidebar.Geometry.TetrahedronGeometry.js +74 -0
- package/src/editor/js/Sidebar.Geometry.TextGeometry.js +136 -0
- package/src/editor/js/Sidebar.Geometry.TorusGeometry.js +109 -0
- package/src/editor/js/Sidebar.Geometry.TorusKnotGeometry.js +121 -0
- package/src/editor/js/Sidebar.Geometry.TubeGeometry.js +135 -0
- package/src/editor/js/Sidebar.Geometry.js +471 -0
- package/src/editor/js/Sidebar.Material.BooleanProperty.js +60 -0
- package/src/editor/js/Sidebar.Material.ColorProperty.js +87 -0
- package/src/editor/js/Sidebar.Material.ConstantProperty.js +62 -0
- package/src/editor/js/Sidebar.Material.MapProperty.js +277 -0
- package/src/editor/js/Sidebar.Material.NumberProperty.js +60 -0
- package/src/editor/js/Sidebar.Material.Program.js +73 -0
- package/src/editor/js/Sidebar.Material.RangeValueProperty.js +63 -0
- package/src/editor/js/Sidebar.Material.js +751 -0
- package/src/editor/js/Sidebar.Object.js +892 -0
- package/src/editor/js/Sidebar.Project.App.js +218 -0
- package/src/editor/js/Sidebar.Project.Materials.js +82 -0
- package/src/editor/js/Sidebar.Project.Renderer.js +193 -0
- package/src/editor/js/Sidebar.Project.Resources.js +242 -0
- package/src/editor/js/Sidebar.Project.js +21 -0
- package/src/editor/js/Sidebar.Properties.js +73 -0
- package/src/editor/js/Sidebar.Scene.js +643 -0
- package/src/editor/js/Sidebar.Script.js +129 -0
- package/src/editor/js/Sidebar.Settings.History.js +146 -0
- package/src/editor/js/Sidebar.Settings.Shortcuts.js +198 -0
- package/src/editor/js/Sidebar.Settings.js +58 -0
- package/src/editor/js/Sidebar.js +41 -0
- package/src/editor/js/Storage.js +98 -0
- package/src/editor/js/Strings.js +2718 -0
- package/src/editor/js/TextureParametersDialog.js +293 -0
- package/src/editor/js/Toolbar.js +75 -0
- package/src/editor/js/Viewport.Controls.js +98 -0
- package/src/editor/js/Viewport.Info.js +144 -0
- package/src/editor/js/Viewport.Pathtracer.js +27 -0
- package/src/editor/js/Viewport.ViewHelper.js +41 -0
- package/src/editor/js/Viewport.XR.js +7 -0
- package/src/editor/js/Viewport.js +982 -0
- package/src/editor/js/commands/AddObjectCommand.js +68 -0
- package/src/editor/js/commands/AddScriptCommand.js +75 -0
- package/src/editor/js/commands/Commands.js +24 -0
- package/src/editor/js/commands/MoveObjectCommand.js +117 -0
- package/src/editor/js/commands/MultiCmdsCommand.js +85 -0
- package/src/editor/js/commands/RemoveObjectCommand.js +88 -0
- package/src/editor/js/commands/RemoveScriptCommand.js +81 -0
- package/src/editor/js/commands/SetColorCommand.js +73 -0
- package/src/editor/js/commands/SetGeometryCommand.js +86 -0
- package/src/editor/js/commands/SetGeometryValueCommand.js +70 -0
- package/src/editor/js/commands/SetMaterialColorCommand.js +87 -0
- package/src/editor/js/commands/SetMaterialCommand.js +80 -0
- package/src/editor/js/commands/SetMaterialMapCommand.js +144 -0
- package/src/editor/js/commands/SetMaterialRangeCommand.js +92 -0
- package/src/editor/js/commands/SetMaterialValueCommand.js +91 -0
- package/src/editor/js/commands/SetMaterialVectorCommand.js +88 -0
- package/src/editor/js/commands/SetPositionCommand.js +84 -0
- package/src/editor/js/commands/SetRotationCommand.js +84 -0
- package/src/editor/js/commands/SetScaleCommand.js +84 -0
- package/src/editor/js/commands/SetSceneCommand.js +104 -0
- package/src/editor/js/commands/SetScriptValueCommand.js +80 -0
- package/src/editor/js/commands/SetShadowValueCommand.js +73 -0
- package/src/editor/js/commands/SetTextureParametersCommand.js +143 -0
- package/src/editor/js/commands/SetUuidCommand.js +70 -0
- package/src/editor/js/commands/SetValueCommand.js +75 -0
- package/src/editor/js/libs/acorn/acorn.js +3236 -0
- package/src/editor/js/libs/acorn/acorn_loose.js +1299 -0
- package/src/editor/js/libs/acorn/walk.js +344 -0
- package/src/editor/js/libs/app/index.html +51 -0
- package/src/editor/js/libs/app.js +14 -0
- package/src/editor/js/libs/codemirror/addon/dialog.css +32 -0
- package/src/editor/js/libs/codemirror/addon/dialog.js +163 -0
- package/src/editor/js/libs/codemirror/addon/show-hint.css +36 -0
- package/src/editor/js/libs/codemirror/addon/show-hint.js +529 -0
- package/src/editor/js/libs/codemirror/addon/tern.css +87 -0
- package/src/editor/js/libs/codemirror/addon/tern.js +750 -0
- package/src/editor/js/libs/codemirror/codemirror.css +344 -0
- package/src/editor/js/libs/codemirror/codemirror.js +9849 -0
- package/src/editor/js/libs/codemirror/mode/glsl.js +233 -0
- package/src/editor/js/libs/codemirror/mode/javascript.js +959 -0
- package/src/editor/js/libs/codemirror/theme/monokai.css +41 -0
- package/src/editor/js/libs/esprima.js +6401 -0
- package/src/editor/js/libs/jsonlint.js +453 -0
- package/src/editor/js/libs/signals.min.js +14 -0
- package/src/editor/js/libs/tern-threejs/build-defs.js +233 -0
- package/src/editor/js/libs/ternjs/comment.js +87 -0
- package/src/editor/js/libs/ternjs/def.js +588 -0
- package/src/editor/js/libs/ternjs/doc_comment.js +401 -0
- package/src/editor/js/libs/ternjs/infer.js +1635 -0
- package/src/editor/js/libs/ternjs/polyfill.js +80 -0
- package/src/editor/js/libs/ternjs/signal.js +26 -0
- package/src/editor/js/libs/ternjs/tern.js +993 -0
- package/src/editor/js/libs/ui.js +1305 -0
- package/src/editor/js/libs/ui.three.js +946 -0
- package/src/events.js +273 -0
- package/src/index.js +284 -0
- package/src/presets/machines.js +239 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
|
|
3
|
+
const STATUS_COLOR = { run: 0x2f9e6b, idle: 0xe0a800, err: 0xc0392b };
|
|
4
|
+
|
|
5
|
+
const matPedestal = new THREE.MeshStandardMaterial( { color: 0x2b3440, roughness: 0.8, metalness: 0.2 } );
|
|
6
|
+
const matBlue = new THREE.MeshStandardMaterial( { color: 0x1b4a8a, roughness: 0.5, metalness: 0.35 } );
|
|
7
|
+
const matWhite = new THREE.MeshStandardMaterial( { color: 0xeef1f5, roughness: 0.55, metalness: 0.15 } );
|
|
8
|
+
const matCrown = new THREE.MeshStandardMaterial( { color: 0xdfe4ea, roughness: 0.6, metalness: 0.15 } );
|
|
9
|
+
const matDark = new THREE.MeshStandardMaterial( { color: 0x141a22, roughness: 0.6 } );
|
|
10
|
+
const matYellow = new THREE.MeshStandardMaterial( { color: 0xf2c037, roughness: 0.6 } );
|
|
11
|
+
const matSteel = new THREE.MeshStandardMaterial( { color: 0x9aa7b6, roughness: 0.4, metalness: 0.6 } );
|
|
12
|
+
|
|
13
|
+
function randomStatus() {
|
|
14
|
+
|
|
15
|
+
const r = Math.random();
|
|
16
|
+
return r < 0.7 ? 'run' : r < 0.9 ? 'idle' : 'err';
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function resolveStatus( params ) {
|
|
21
|
+
|
|
22
|
+
if ( params && params.status ) return params.status;
|
|
23
|
+
return randomStatus();
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function makeBeacon( status, y ) {
|
|
28
|
+
|
|
29
|
+
const color = STATUS_COLOR[ status ];
|
|
30
|
+
const mat = new THREE.MeshStandardMaterial( {
|
|
31
|
+
color,
|
|
32
|
+
emissive: color,
|
|
33
|
+
emissiveIntensity: 0.85,
|
|
34
|
+
roughness: 0.4
|
|
35
|
+
} );
|
|
36
|
+
const beacon = new THREE.Mesh( new THREE.SphereGeometry( 0.8, 18, 18 ), mat );
|
|
37
|
+
beacon.position.set( 0, y, 0 );
|
|
38
|
+
beacon.castShadow = true;
|
|
39
|
+
beacon.userData = { role: 'beacon' };
|
|
40
|
+
return { mesh: beacon, mat, pole: makePole( y - 1.5 ) };
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function makePole( y ) {
|
|
45
|
+
|
|
46
|
+
const pole = new THREE.Mesh( new THREE.CylinderGeometry( 0.18, 0.18, 3, 8 ), matSteel );
|
|
47
|
+
pole.position.y = y;
|
|
48
|
+
pole.castShadow = true;
|
|
49
|
+
return pole;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function smallBox( group, w, h, d, topMaterial, bottomMaterial ) {
|
|
54
|
+
|
|
55
|
+
const b = new THREE.Mesh( new THREE.BoxGeometry( w, h * 0.5, d ), bottomMaterial );
|
|
56
|
+
b.position.set( 0, h * 0.25, 0 );
|
|
57
|
+
b.castShadow = true; b.receiveShadow = true;
|
|
58
|
+
const t = new THREE.Mesh( new THREE.BoxGeometry( w * 0.95, h * 0.5, d * 0.95 ), topMaterial );
|
|
59
|
+
t.position.set( 0, h * 0.75, 0 );
|
|
60
|
+
t.castShadow = true; t.receiveShadow = true;
|
|
61
|
+
group.add( b, t );
|
|
62
|
+
return t;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function createPressMachine( x = 0, z = 0, params = {} ) {
|
|
67
|
+
|
|
68
|
+
const ton = params.ton || 600;
|
|
69
|
+
const g = new THREE.Group();
|
|
70
|
+
const s = ton >= 1000 ? 1.25 : ton >= 800 ? 1.15 : ton >= 600 ? 1.05 : 0.95;
|
|
71
|
+
const w = 7.5 * s, d = 8.5 * s;
|
|
72
|
+
|
|
73
|
+
const ped = new THREE.Mesh( new THREE.BoxGeometry( w, 1.4, d ), matPedestal );
|
|
74
|
+
ped.position.y = 0.7; ped.castShadow = true; ped.receiveShadow = true;
|
|
75
|
+
const stripe = new THREE.Mesh( new THREE.BoxGeometry( w + 0.3, 0.5, d + 0.3 ), matYellow );
|
|
76
|
+
stripe.position.y = 1.45; stripe.castShadow = true;
|
|
77
|
+
const lower = new THREE.Mesh( new THREE.BoxGeometry( w * 0.86, 6.5 * s, d * 0.7 ), matBlue );
|
|
78
|
+
lower.position.y = 1.4 + 3.25 * s; lower.castShadow = true; lower.receiveShadow = true;
|
|
79
|
+
const upper = new THREE.Mesh( new THREE.BoxGeometry( w * 0.86, 5.5 * s, d * 0.7 ), matWhite );
|
|
80
|
+
upper.position.y = 1.4 + 6.5 * s + 2.75 * s; upper.castShadow = true; upper.receiveShadow = true;
|
|
81
|
+
const slot = new THREE.Mesh( new THREE.BoxGeometry( w * 0.6, 3 * s, d * 0.75 ), matDark );
|
|
82
|
+
slot.position.set( 0, 1.4 + 2.4 * s, 0 ); slot.castShadow = true;
|
|
83
|
+
const crown = new THREE.Mesh( new THREE.BoxGeometry( w, 2.6 * s, d ), matCrown );
|
|
84
|
+
crown.position.y = 1.4 + 12 * s + 1.3 * s; crown.castShadow = true; crown.receiveShadow = true;
|
|
85
|
+
|
|
86
|
+
g.add( ped, stripe, lower, upper, slot, crown );
|
|
87
|
+
|
|
88
|
+
const btop = 1.4 + 12 * s + 2.6 * s + 1.6;
|
|
89
|
+
const { mesh: beacon, pole } = makeBeacon( resolveStatus( params ), btop );
|
|
90
|
+
g.add( pole, beacon );
|
|
91
|
+
|
|
92
|
+
g.position.set( x, 0, z );
|
|
93
|
+
g.userData = {
|
|
94
|
+
type: 'machine',
|
|
95
|
+
name: params.name || ( 'Press ' + ton + 'T' ),
|
|
96
|
+
ton,
|
|
97
|
+
status: beacon.userData.status
|
|
98
|
+
};
|
|
99
|
+
beacon.userData.status = g.userData.status;
|
|
100
|
+
return g;
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createSinglePress( x = 0, z = 0, params = {} ) {
|
|
105
|
+
|
|
106
|
+
const ton = params.ton || 100;
|
|
107
|
+
const g = new THREE.Group();
|
|
108
|
+
smallBox( g, 6, 7, 6, matWhite, matBlue );
|
|
109
|
+
const { mesh: beacon, pole } = makeBeacon( resolveStatus( params ), 8 );
|
|
110
|
+
g.add( pole, beacon );
|
|
111
|
+
g.position.set( x, 0, z );
|
|
112
|
+
g.userData = {
|
|
113
|
+
type: 'machine',
|
|
114
|
+
name: params.name || ( 'Single Press ' + ton + 'T' ),
|
|
115
|
+
ton,
|
|
116
|
+
status: beacon.userData.status
|
|
117
|
+
};
|
|
118
|
+
beacon.userData.status = g.userData.status;
|
|
119
|
+
return g;
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function createAmada( x = 0, z = 0, params = {} ) {
|
|
124
|
+
|
|
125
|
+
const g = new THREE.Group();
|
|
126
|
+
smallBox( g, 8, 9, 8, matWhite, matDark );
|
|
127
|
+
const { mesh: beacon, pole } = makeBeacon( resolveStatus( params ), 10 );
|
|
128
|
+
g.add( pole, beacon );
|
|
129
|
+
g.position.set( x, 0, z );
|
|
130
|
+
g.userData = {
|
|
131
|
+
type: 'machine',
|
|
132
|
+
name: params.name || 'Amada',
|
|
133
|
+
status: beacon.userData.status
|
|
134
|
+
};
|
|
135
|
+
beacon.userData.status = g.userData.status;
|
|
136
|
+
return g;
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function createCompressor( x = 0, z = 0, params = {} ) {
|
|
141
|
+
|
|
142
|
+
const g = new THREE.Group();
|
|
143
|
+
const tank = new THREE.Mesh( new THREE.CylinderGeometry( 2.6, 2.6, 10, 24 ), matSteel );
|
|
144
|
+
tank.position.y = 5; tank.castShadow = true;
|
|
145
|
+
const cap = new THREE.Mesh( new THREE.SphereGeometry( 2.6, 20, 12, 0, 6.28, 0, 1.57 ), matSteel );
|
|
146
|
+
cap.position.y = 10;
|
|
147
|
+
const unit = new THREE.Mesh( new THREE.BoxGeometry( 5, 4, 4 ), matBlue );
|
|
148
|
+
unit.position.set( 4, 2, 0 ); unit.castShadow = true;
|
|
149
|
+
g.add( tank, cap, unit );
|
|
150
|
+
const { mesh: beacon, pole } = makeBeacon( resolveStatus( params ), 12 );
|
|
151
|
+
g.add( pole, beacon );
|
|
152
|
+
g.position.set( x, 0, z );
|
|
153
|
+
g.userData = {
|
|
154
|
+
type: 'machine',
|
|
155
|
+
name: params.name || 'Air Compressor',
|
|
156
|
+
press: '8.0 bar',
|
|
157
|
+
status: beacon.userData.status
|
|
158
|
+
};
|
|
159
|
+
beacon.userData.status = g.userData.status;
|
|
160
|
+
return g;
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function createCoilLine( x = 0, z = 0, params = {} ) {
|
|
165
|
+
|
|
166
|
+
const g = new THREE.Group();
|
|
167
|
+
smallBox( g, 6, 7, 7, matWhite, matBlue );
|
|
168
|
+
const coil = new THREE.Mesh( new THREE.CylinderGeometry( 2.4, 2.4, 4, 20 ), matSteel );
|
|
169
|
+
coil.rotation.z = Math.PI / 2;
|
|
170
|
+
coil.position.set( - 5.5, 3, 0 );
|
|
171
|
+
coil.castShadow = true;
|
|
172
|
+
g.add( coil );
|
|
173
|
+
const { mesh: beacon, pole } = makeBeacon( resolveStatus( params ), 10 );
|
|
174
|
+
g.add( pole, beacon );
|
|
175
|
+
g.position.set( x, 0, z );
|
|
176
|
+
g.userData = {
|
|
177
|
+
type: 'machine',
|
|
178
|
+
name: params.name || 'Coil Line 600T',
|
|
179
|
+
status: beacon.userData.status
|
|
180
|
+
};
|
|
181
|
+
beacon.userData.status = g.userData.status;
|
|
182
|
+
return g;
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const BUILTIN_PRESETS = {
|
|
187
|
+
'press-machine': createPressMachine,
|
|
188
|
+
'single-press': createSinglePress,
|
|
189
|
+
'amada': createAmada,
|
|
190
|
+
'compressor': createCompressor,
|
|
191
|
+
'coil-line': createCoilLine
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const PRESETS = Object.assign( {}, BUILTIN_PRESETS );
|
|
195
|
+
|
|
196
|
+
let _registered = false;
|
|
197
|
+
function registerBuiltinPresets() {
|
|
198
|
+
|
|
199
|
+
if ( _registered ) return PRESETS;
|
|
200
|
+
_registered = true;
|
|
201
|
+
Object.assign( PRESETS, BUILTIN_PRESETS );
|
|
202
|
+
return PRESETS;
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function registerPreset( name, factory ) {
|
|
207
|
+
|
|
208
|
+
if ( typeof factory !== 'function' ) throw new Error( 'registerPreset: factory must be a function' );
|
|
209
|
+
PRESETS[ name ] = factory;
|
|
210
|
+
return PRESETS;
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function createPreset( name, x = 0, z = 0, params ) {
|
|
215
|
+
|
|
216
|
+
const factory = PRESETS[ name ] || BUILTIN_PRESETS[ name ];
|
|
217
|
+
if ( ! factory ) {
|
|
218
|
+
|
|
219
|
+
console.warn( 'createPreset: unknown preset "' + name + '"' );
|
|
220
|
+
return null;
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
return factory( x, z, params || {} );
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
PRESETS,
|
|
229
|
+
BUILTIN_PRESETS,
|
|
230
|
+
STATUS_COLOR,
|
|
231
|
+
registerBuiltinPresets,
|
|
232
|
+
registerPreset,
|
|
233
|
+
createPreset,
|
|
234
|
+
createPressMachine,
|
|
235
|
+
createSinglePress,
|
|
236
|
+
createAmada,
|
|
237
|
+
createCompressor,
|
|
238
|
+
createCoilLine
|
|
239
|
+
};
|