spoint 0.1.0 → 0.1.10
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 +134 -209
- package/SKILL.md +95 -0
- package/apps/environment/index.js +200 -1
- package/apps/environment/models/decorative/.gitkeep +0 -0
- package/apps/environment/models/hazards/.gitkeep +0 -0
- package/apps/environment/models/interactive/.gitkeep +0 -0
- package/apps/environment/models/structures/.gitkeep +0 -0
- package/apps/environment/smartObjects.js +114 -0
- package/apps/interactable/index.js +155 -0
- package/apps/physics-crate/index.js +15 -9
- package/apps/power-crate/index.js +18 -12
- package/apps/tps-game/$GDUPI.vrm +0 -0
- package/apps/tps-game/Cleetus.vrm +0 -0
- package/apps/tps-game/index.js +185 -27
- package/apps/world/index.js +68 -22
- package/bin/create-app.js +337 -0
- package/client/ARControls.js +301 -0
- package/client/LoadingManager.js +117 -0
- package/client/MobileControls.js +1122 -0
- package/client/anim-lib.glb +0 -0
- package/client/animation.js +306 -0
- package/client/app.js +1341 -65
- package/client/camera.js +191 -33
- package/client/createLoadingScreen.js +69 -0
- package/client/editor/bridge.js +113 -0
- package/client/editor/css/main.css +794 -0
- package/client/editor/images/rotate.svg +4 -0
- package/client/editor/images/scale.svg +4 -0
- package/client/editor/images/translate.svg +4 -0
- package/client/editor/index.html +103 -0
- package/client/editor/js/Command.js +41 -0
- package/client/editor/js/Config.js +81 -0
- package/client/editor/js/Editor.js +785 -0
- package/client/editor/js/EditorControls.js +438 -0
- package/client/editor/js/History.js +321 -0
- package/client/editor/js/Loader.js +987 -0
- package/client/editor/js/LoaderUtils.js +90 -0
- package/client/editor/js/Menubar.Add.js +510 -0
- package/client/editor/js/Menubar.Edit.js +145 -0
- package/client/editor/js/Menubar.File.js +466 -0
- package/client/editor/js/Menubar.Help.js +73 -0
- package/client/editor/js/Menubar.Status.js +51 -0
- package/client/editor/js/Menubar.View.js +183 -0
- package/client/editor/js/Menubar.js +27 -0
- package/client/editor/js/Player.js +53 -0
- package/client/editor/js/Resizer.js +58 -0
- package/client/editor/js/Script.js +503 -0
- package/client/editor/js/Selector.js +102 -0
- package/client/editor/js/Sidebar.Geometry.BoxGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.BufferGeometry.js +115 -0
- package/client/editor/js/Sidebar.Geometry.CapsuleGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.CircleGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.CylinderGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.DodecahedronGeometry.js +73 -0
- package/client/editor/js/Sidebar.Geometry.ExtrudeGeometry.js +196 -0
- package/client/editor/js/Sidebar.Geometry.IcosahedronGeometry.js +73 -0
- package/client/editor/js/Sidebar.Geometry.LatheGeometry.js +98 -0
- package/client/editor/js/Sidebar.Geometry.Modifiers.js +73 -0
- package/client/editor/js/Sidebar.Geometry.OctahedronGeometry.js +74 -0
- package/client/editor/js/Sidebar.Geometry.PlaneGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.RingGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.ShapeGeometry.js +76 -0
- package/client/editor/js/Sidebar.Geometry.SphereGeometry.js +133 -0
- package/client/editor/js/Sidebar.Geometry.TetrahedronGeometry.js +74 -0
- package/client/editor/js/Sidebar.Geometry.TorusGeometry.js +109 -0
- package/client/editor/js/Sidebar.Geometry.TorusKnotGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.TubeGeometry.js +135 -0
- package/client/editor/js/Sidebar.Geometry.js +332 -0
- package/client/editor/js/Sidebar.Material.BooleanProperty.js +60 -0
- package/client/editor/js/Sidebar.Material.ColorProperty.js +87 -0
- package/client/editor/js/Sidebar.Material.ConstantProperty.js +62 -0
- package/client/editor/js/Sidebar.Material.MapProperty.js +249 -0
- package/client/editor/js/Sidebar.Material.NumberProperty.js +60 -0
- package/client/editor/js/Sidebar.Material.Program.js +73 -0
- package/client/editor/js/Sidebar.Material.RangeValueProperty.js +63 -0
- package/client/editor/js/Sidebar.Material.js +751 -0
- package/client/editor/js/Sidebar.Object.Animation.js +102 -0
- package/client/editor/js/Sidebar.Object.js +898 -0
- package/client/editor/js/Sidebar.Project.App.js +165 -0
- package/client/editor/js/Sidebar.Project.Image.js +225 -0
- package/client/editor/js/Sidebar.Project.Materials.js +82 -0
- package/client/editor/js/Sidebar.Project.Renderer.js +144 -0
- package/client/editor/js/Sidebar.Project.Video.js +242 -0
- package/client/editor/js/Sidebar.Project.js +31 -0
- package/client/editor/js/Sidebar.Properties.js +73 -0
- package/client/editor/js/Sidebar.Scene.js +585 -0
- package/client/editor/js/Sidebar.Script.js +129 -0
- package/client/editor/js/Sidebar.Settings.History.js +146 -0
- package/client/editor/js/Sidebar.Settings.Shortcuts.js +175 -0
- package/client/editor/js/Sidebar.Settings.js +60 -0
- package/client/editor/js/Sidebar.js +41 -0
- package/client/editor/js/Storage.js +98 -0
- package/client/editor/js/Strings.js +2028 -0
- package/client/editor/js/Toolbar.js +84 -0
- package/client/editor/js/Viewport.Controls.js +92 -0
- package/client/editor/js/Viewport.Info.js +136 -0
- package/client/editor/js/Viewport.Pathtracer.js +91 -0
- package/client/editor/js/Viewport.ViewHelper.js +39 -0
- package/client/editor/js/Viewport.XR.js +222 -0
- package/client/editor/js/Viewport.js +900 -0
- package/client/editor/js/commands/AddObjectCommand.js +68 -0
- package/client/editor/js/commands/AddScriptCommand.js +75 -0
- package/client/editor/js/commands/Commands.js +23 -0
- package/client/editor/js/commands/MoveObjectCommand.js +111 -0
- package/client/editor/js/commands/MultiCmdsCommand.js +85 -0
- package/client/editor/js/commands/RemoveObjectCommand.js +88 -0
- package/client/editor/js/commands/RemoveScriptCommand.js +81 -0
- package/client/editor/js/commands/SetColorCommand.js +73 -0
- package/client/editor/js/commands/SetGeometryCommand.js +87 -0
- package/client/editor/js/commands/SetGeometryValueCommand.js +70 -0
- package/client/editor/js/commands/SetMaterialColorCommand.js +86 -0
- package/client/editor/js/commands/SetMaterialCommand.js +79 -0
- package/client/editor/js/commands/SetMaterialMapCommand.js +143 -0
- package/client/editor/js/commands/SetMaterialRangeCommand.js +91 -0
- package/client/editor/js/commands/SetMaterialValueCommand.js +90 -0
- package/client/editor/js/commands/SetMaterialVectorCommand.js +79 -0
- package/client/editor/js/commands/SetPositionCommand.js +84 -0
- package/client/editor/js/commands/SetRotationCommand.js +84 -0
- package/client/editor/js/commands/SetScaleCommand.js +84 -0
- package/client/editor/js/commands/SetSceneCommand.js +103 -0
- package/client/editor/js/commands/SetScriptValueCommand.js +80 -0
- package/client/editor/js/commands/SetShadowValueCommand.js +73 -0
- package/client/editor/js/commands/SetUuidCommand.js +70 -0
- package/client/editor/js/commands/SetValueCommand.js +75 -0
- package/client/editor/js/libs/acorn/acorn.js +3236 -0
- package/client/editor/js/libs/acorn/acorn_loose.js +1299 -0
- package/client/editor/js/libs/acorn/walk.js +344 -0
- package/client/editor/js/libs/app/index.html +57 -0
- package/client/editor/js/libs/app.js +251 -0
- package/client/editor/js/libs/codemirror/addon/dialog.css +32 -0
- package/client/editor/js/libs/codemirror/addon/dialog.js +163 -0
- package/client/editor/js/libs/codemirror/addon/show-hint.css +36 -0
- package/client/editor/js/libs/codemirror/addon/show-hint.js +529 -0
- package/client/editor/js/libs/codemirror/addon/tern.css +87 -0
- package/client/editor/js/libs/codemirror/addon/tern.js +750 -0
- package/client/editor/js/libs/codemirror/codemirror.css +344 -0
- package/client/editor/js/libs/codemirror/codemirror.js +9849 -0
- package/client/editor/js/libs/codemirror/mode/glsl.js +233 -0
- package/client/editor/js/libs/codemirror/mode/javascript.js +959 -0
- package/client/editor/js/libs/codemirror/theme/monokai.css +41 -0
- package/client/editor/js/libs/esprima.js +6401 -0
- package/client/editor/js/libs/jsonlint.js +453 -0
- package/client/editor/js/libs/signals.min.js +14 -0
- package/client/editor/js/libs/tern-threejs/threejs.js +5031 -0
- package/client/editor/js/libs/ternjs/comment.js +87 -0
- package/client/editor/js/libs/ternjs/def.js +588 -0
- package/client/editor/js/libs/ternjs/doc_comment.js +401 -0
- package/client/editor/js/libs/ternjs/infer.js +1635 -0
- package/client/editor/js/libs/ternjs/polyfill.js +80 -0
- package/client/editor/js/libs/ternjs/signal.js +26 -0
- package/client/editor/js/libs/ternjs/tern.js +993 -0
- package/client/editor/js/libs/ui.js +1346 -0
- package/client/editor/js/libs/ui.three.js +855 -0
- package/client/facial-animation.js +455 -0
- package/client/index.html +7 -4
- package/client/loading.css +147 -0
- package/client/loading.html +25 -0
- package/client/style.css +251 -0
- package/package.json +7 -3
- package/server.js +9 -1
- package/src/apps/AppContext.js +1 -1
- package/src/apps/AppLoader.js +50 -37
- package/src/apps/AppRuntime.js +32 -8
- package/src/client/InputHandler.js +233 -0
- package/src/client/JitterBuffer.js +207 -0
- package/src/client/KalmanFilter.js +125 -0
- package/src/client/MessageHandler.js +101 -0
- package/src/client/PhysicsNetworkClient.js +141 -68
- package/src/client/ReconnectManager.js +62 -0
- package/src/client/SmoothInterpolation.js +127 -0
- package/src/client/SnapshotProcessor.js +144 -0
- package/src/connection/ConnectionManager.js +21 -3
- package/src/connection/SessionStore.js +13 -3
- package/src/index.client.js +4 -6
- package/src/netcode/EventLog.js +29 -15
- package/src/netcode/LagCompensator.js +25 -26
- package/src/netcode/NetworkState.js +4 -1
- package/src/netcode/PhysicsIntegration.js +20 -6
- package/src/netcode/PlayerManager.js +10 -2
- package/src/netcode/SnapshotEncoder.js +66 -19
- package/src/netcode/TickSystem.js +13 -4
- package/src/physics/World.js +66 -13
- package/src/protocol/msgpack.js +90 -63
- package/src/sdk/ReloadHandlers.js +12 -2
- package/src/sdk/ReloadManager.js +5 -0
- package/src/sdk/ServerHandlers.js +50 -11
- package/src/sdk/StaticHandler.js +22 -6
- package/src/sdk/TickHandler.js +101 -34
- package/src/sdk/scaffold.js +28 -0
- package/src/sdk/server.js +59 -33
- package/src/shared/movement.js +2 -1
- package/src/spatial/Octree.js +5 -0
- package/apps/interactive-door/index.js +0 -33
- package/apps/patrol-npc/index.js +0 -37
- package/src/connection/QualityMonitor.js +0 -46
- package/src/debug/StateInspector.js +0 -42
- package/src/index.js +0 -1
- package/src/index.server.js +0 -27
- package/src/protocol/Codec.js +0 -60
- package/src/protocol/SequenceTracker.js +0 -71
- package/src/sdk/ClientMessageHandler.js +0 -80
- package/src/sdk/client.js +0 -122
- package/world/kaira.glb +0 -0
- package/world/schwust.glb +0 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
|
|
3
|
+
import { UIPanel, UIBreak, UIRow, UIColor, UISelect, UIText, UINumber } from './libs/ui.js';
|
|
4
|
+
import { UIOutliner, UITexture } from './libs/ui.three.js';
|
|
5
|
+
|
|
6
|
+
function SidebarScene( editor ) {
|
|
7
|
+
|
|
8
|
+
const signals = editor.signals;
|
|
9
|
+
const strings = editor.strings;
|
|
10
|
+
|
|
11
|
+
const container = new UIPanel();
|
|
12
|
+
container.setBorderTop( '0' );
|
|
13
|
+
container.setPaddingTop( '20px' );
|
|
14
|
+
|
|
15
|
+
// outliner
|
|
16
|
+
|
|
17
|
+
const nodeStates = new WeakMap();
|
|
18
|
+
|
|
19
|
+
function buildOption( object, draggable ) {
|
|
20
|
+
|
|
21
|
+
const option = document.createElement( 'div' );
|
|
22
|
+
option.draggable = draggable;
|
|
23
|
+
option.innerHTML = buildHTML( object );
|
|
24
|
+
option.value = object.id;
|
|
25
|
+
|
|
26
|
+
// opener
|
|
27
|
+
|
|
28
|
+
if ( nodeStates.has( object ) ) {
|
|
29
|
+
|
|
30
|
+
const state = nodeStates.get( object );
|
|
31
|
+
|
|
32
|
+
const opener = document.createElement( 'span' );
|
|
33
|
+
opener.classList.add( 'opener' );
|
|
34
|
+
|
|
35
|
+
if ( object.children.length > 0 ) {
|
|
36
|
+
|
|
37
|
+
opener.classList.add( state ? 'open' : 'closed' );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
opener.addEventListener( 'click', function () {
|
|
42
|
+
|
|
43
|
+
nodeStates.set( object, nodeStates.get( object ) === false ); // toggle
|
|
44
|
+
refreshUI();
|
|
45
|
+
|
|
46
|
+
} );
|
|
47
|
+
|
|
48
|
+
option.insertBefore( opener, option.firstChild );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return option;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getMaterialName( material ) {
|
|
57
|
+
|
|
58
|
+
if ( Array.isArray( material ) ) {
|
|
59
|
+
|
|
60
|
+
const array = [];
|
|
61
|
+
|
|
62
|
+
for ( let i = 0; i < material.length; i ++ ) {
|
|
63
|
+
|
|
64
|
+
array.push( material[ i ].name );
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return array.join( ',' );
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return material.name;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function escapeHTML( html ) {
|
|
77
|
+
|
|
78
|
+
return html
|
|
79
|
+
.replace( /&/g, '&' )
|
|
80
|
+
.replace( /"/g, '"' )
|
|
81
|
+
.replace( /'/g, ''' )
|
|
82
|
+
.replace( /</g, '<' )
|
|
83
|
+
.replace( />/g, '>' );
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getObjectType( object ) {
|
|
88
|
+
|
|
89
|
+
if ( object.isScene ) return 'Scene';
|
|
90
|
+
if ( object.isCamera ) return 'Camera';
|
|
91
|
+
if ( object.isLight ) return 'Light';
|
|
92
|
+
if ( object.isMesh ) return 'Mesh';
|
|
93
|
+
if ( object.isLine ) return 'Line';
|
|
94
|
+
if ( object.isPoints ) return 'Points';
|
|
95
|
+
|
|
96
|
+
return 'Object3D';
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function buildHTML( object ) {
|
|
101
|
+
|
|
102
|
+
let html = `<span class="type ${ getObjectType( object ) }"></span> ${ escapeHTML( object.name ) }`;
|
|
103
|
+
|
|
104
|
+
if ( object.isMesh ) {
|
|
105
|
+
|
|
106
|
+
const geometry = object.geometry;
|
|
107
|
+
const material = object.material;
|
|
108
|
+
|
|
109
|
+
html += ` <span class="type Geometry"></span> ${ escapeHTML( geometry.name ) }`;
|
|
110
|
+
html += ` <span class="type Material"></span> ${ escapeHTML( getMaterialName( material ) ) }`;
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
html += getScript( object.uuid );
|
|
115
|
+
|
|
116
|
+
return html;
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function getScript( uuid ) {
|
|
121
|
+
|
|
122
|
+
if ( editor.scripts[ uuid ] === undefined ) return '';
|
|
123
|
+
|
|
124
|
+
if ( editor.scripts[ uuid ].length === 0 ) return '';
|
|
125
|
+
|
|
126
|
+
return ' <span class="type Script"></span>';
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let ignoreObjectSelectedSignal = false;
|
|
131
|
+
|
|
132
|
+
const outliner = new UIOutliner( editor );
|
|
133
|
+
outliner.setId( 'outliner' );
|
|
134
|
+
outliner.onChange( function () {
|
|
135
|
+
|
|
136
|
+
ignoreObjectSelectedSignal = true;
|
|
137
|
+
|
|
138
|
+
editor.selectById( parseInt( outliner.getValue() ) );
|
|
139
|
+
|
|
140
|
+
ignoreObjectSelectedSignal = false;
|
|
141
|
+
|
|
142
|
+
} );
|
|
143
|
+
outliner.onDblClick( function () {
|
|
144
|
+
|
|
145
|
+
editor.focusById( parseInt( outliner.getValue() ) );
|
|
146
|
+
|
|
147
|
+
} );
|
|
148
|
+
container.add( outliner );
|
|
149
|
+
container.add( new UIBreak() );
|
|
150
|
+
|
|
151
|
+
// background
|
|
152
|
+
|
|
153
|
+
const backgroundRow = new UIRow();
|
|
154
|
+
|
|
155
|
+
const backgroundType = new UISelect().setOptions( {
|
|
156
|
+
|
|
157
|
+
'None': '',
|
|
158
|
+
'Color': 'Color',
|
|
159
|
+
'Texture': 'Texture',
|
|
160
|
+
'Equirectangular': 'Equirect'
|
|
161
|
+
|
|
162
|
+
} ).setWidth( '150px' );
|
|
163
|
+
backgroundType.onChange( function () {
|
|
164
|
+
|
|
165
|
+
onBackgroundChanged();
|
|
166
|
+
refreshBackgroundUI();
|
|
167
|
+
|
|
168
|
+
} );
|
|
169
|
+
|
|
170
|
+
backgroundRow.add( new UIText( strings.getKey( 'sidebar/scene/background' ) ).setClass( 'Label' ) );
|
|
171
|
+
backgroundRow.add( backgroundType );
|
|
172
|
+
|
|
173
|
+
const backgroundColor = new UIColor().setValue( '#000000' ).setMarginLeft( '8px' ).onInput( onBackgroundChanged );
|
|
174
|
+
backgroundRow.add( backgroundColor );
|
|
175
|
+
|
|
176
|
+
const backgroundTexture = new UITexture( editor ).setMarginLeft( '8px' ).onChange( onBackgroundChanged );
|
|
177
|
+
backgroundTexture.setDisplay( 'none' );
|
|
178
|
+
backgroundRow.add( backgroundTexture );
|
|
179
|
+
|
|
180
|
+
const backgroundEquirectangularTexture = new UITexture( editor ).setMarginLeft( '8px' ).onChange( onBackgroundChanged );
|
|
181
|
+
backgroundEquirectangularTexture.setDisplay( 'none' );
|
|
182
|
+
backgroundRow.add( backgroundEquirectangularTexture );
|
|
183
|
+
|
|
184
|
+
container.add( backgroundRow );
|
|
185
|
+
|
|
186
|
+
const backgroundEquirectRow = new UIRow();
|
|
187
|
+
backgroundEquirectRow.setDisplay( 'none' );
|
|
188
|
+
backgroundEquirectRow.setMarginLeft( '120px' );
|
|
189
|
+
|
|
190
|
+
const backgroundBlurriness = new UINumber( 0 ).setWidth( '40px' ).setRange( 0, 1 ).onChange( onBackgroundChanged );
|
|
191
|
+
backgroundEquirectRow.add( backgroundBlurriness );
|
|
192
|
+
|
|
193
|
+
const backgroundIntensity = new UINumber( 1 ).setWidth( '40px' ).setRange( 0, Infinity ).onChange( onBackgroundChanged );
|
|
194
|
+
backgroundEquirectRow.add( backgroundIntensity );
|
|
195
|
+
|
|
196
|
+
const backgroundRotation = new UINumber( 0 ).setWidth( '40px' ).setRange( - 180, 180 ).setStep( 10 ).setNudge( 0.1 ).setUnit( '°' ).onChange( onBackgroundChanged );
|
|
197
|
+
backgroundEquirectRow.add( backgroundRotation );
|
|
198
|
+
|
|
199
|
+
container.add( backgroundEquirectRow );
|
|
200
|
+
|
|
201
|
+
function onBackgroundChanged() {
|
|
202
|
+
|
|
203
|
+
signals.sceneBackgroundChanged.dispatch(
|
|
204
|
+
backgroundType.getValue(),
|
|
205
|
+
backgroundColor.getHexValue(),
|
|
206
|
+
backgroundTexture.getValue(),
|
|
207
|
+
backgroundEquirectangularTexture.getValue(),
|
|
208
|
+
backgroundBlurriness.getValue(),
|
|
209
|
+
backgroundIntensity.getValue(),
|
|
210
|
+
backgroundRotation.getValue()
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function refreshBackgroundUI() {
|
|
216
|
+
|
|
217
|
+
const type = backgroundType.getValue();
|
|
218
|
+
|
|
219
|
+
backgroundType.setWidth( type === 'None' ? '150px' : '110px' );
|
|
220
|
+
backgroundColor.setDisplay( type === 'Color' ? '' : 'none' );
|
|
221
|
+
backgroundTexture.setDisplay( type === 'Texture' ? '' : 'none' );
|
|
222
|
+
backgroundEquirectangularTexture.setDisplay( type === 'Equirectangular' ? '' : 'none' );
|
|
223
|
+
backgroundEquirectRow.setDisplay( type === 'Equirectangular' ? '' : 'none' );
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// environment
|
|
228
|
+
|
|
229
|
+
const environmentRow = new UIRow();
|
|
230
|
+
|
|
231
|
+
const environmentType = new UISelect().setOptions( {
|
|
232
|
+
|
|
233
|
+
'None': '',
|
|
234
|
+
'Background': 'Background',
|
|
235
|
+
'Equirectangular': 'Equirect',
|
|
236
|
+
'ModelViewer': 'ModelViewer'
|
|
237
|
+
|
|
238
|
+
} ).setWidth( '150px' );
|
|
239
|
+
environmentType.setValue( 'None' );
|
|
240
|
+
environmentType.onChange( function () {
|
|
241
|
+
|
|
242
|
+
onEnvironmentChanged();
|
|
243
|
+
refreshEnvironmentUI();
|
|
244
|
+
|
|
245
|
+
} );
|
|
246
|
+
|
|
247
|
+
environmentRow.add( new UIText( strings.getKey( 'sidebar/scene/environment' ) ).setClass( 'Label' ) );
|
|
248
|
+
environmentRow.add( environmentType );
|
|
249
|
+
|
|
250
|
+
const environmentEquirectangularTexture = new UITexture( editor ).setMarginLeft( '8px' ).onChange( onEnvironmentChanged );
|
|
251
|
+
environmentEquirectangularTexture.setDisplay( 'none' );
|
|
252
|
+
environmentRow.add( environmentEquirectangularTexture );
|
|
253
|
+
|
|
254
|
+
container.add( environmentRow );
|
|
255
|
+
|
|
256
|
+
function onEnvironmentChanged() {
|
|
257
|
+
|
|
258
|
+
signals.sceneEnvironmentChanged.dispatch(
|
|
259
|
+
environmentType.getValue(),
|
|
260
|
+
environmentEquirectangularTexture.getValue()
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function refreshEnvironmentUI() {
|
|
266
|
+
|
|
267
|
+
const type = environmentType.getValue();
|
|
268
|
+
|
|
269
|
+
environmentType.setWidth( type !== 'Equirectangular' ? '150px' : '110px' );
|
|
270
|
+
environmentEquirectangularTexture.setDisplay( type === 'Equirectangular' ? '' : 'none' );
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// fog
|
|
275
|
+
|
|
276
|
+
function onFogChanged() {
|
|
277
|
+
|
|
278
|
+
signals.sceneFogChanged.dispatch(
|
|
279
|
+
fogType.getValue(),
|
|
280
|
+
fogColor.getHexValue(),
|
|
281
|
+
fogNear.getValue(),
|
|
282
|
+
fogFar.getValue(),
|
|
283
|
+
fogDensity.getValue()
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function onFogSettingsChanged() {
|
|
289
|
+
|
|
290
|
+
signals.sceneFogSettingsChanged.dispatch(
|
|
291
|
+
fogType.getValue(),
|
|
292
|
+
fogColor.getHexValue(),
|
|
293
|
+
fogNear.getValue(),
|
|
294
|
+
fogFar.getValue(),
|
|
295
|
+
fogDensity.getValue()
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const fogTypeRow = new UIRow();
|
|
301
|
+
const fogType = new UISelect().setOptions( {
|
|
302
|
+
|
|
303
|
+
'None': '',
|
|
304
|
+
'Fog': 'Linear',
|
|
305
|
+
'FogExp2': 'Exponential'
|
|
306
|
+
|
|
307
|
+
} ).setWidth( '150px' );
|
|
308
|
+
fogType.onChange( function () {
|
|
309
|
+
|
|
310
|
+
onFogChanged();
|
|
311
|
+
refreshFogUI();
|
|
312
|
+
|
|
313
|
+
} );
|
|
314
|
+
|
|
315
|
+
fogTypeRow.add( new UIText( strings.getKey( 'sidebar/scene/fog' ) ).setClass( 'Label' ) );
|
|
316
|
+
fogTypeRow.add( fogType );
|
|
317
|
+
|
|
318
|
+
container.add( fogTypeRow );
|
|
319
|
+
|
|
320
|
+
// fog color
|
|
321
|
+
|
|
322
|
+
const fogPropertiesRow = new UIRow();
|
|
323
|
+
fogPropertiesRow.setDisplay( 'none' );
|
|
324
|
+
fogPropertiesRow.setMarginLeft( '120px' );
|
|
325
|
+
container.add( fogPropertiesRow );
|
|
326
|
+
|
|
327
|
+
const fogColor = new UIColor().setValue( '#aaaaaa' );
|
|
328
|
+
fogColor.onInput( onFogSettingsChanged );
|
|
329
|
+
fogPropertiesRow.add( fogColor );
|
|
330
|
+
|
|
331
|
+
// fog near
|
|
332
|
+
|
|
333
|
+
const fogNear = new UINumber( 0.1 ).setWidth( '40px' ).setRange( 0, Infinity ).onChange( onFogSettingsChanged );
|
|
334
|
+
fogPropertiesRow.add( fogNear );
|
|
335
|
+
|
|
336
|
+
// fog far
|
|
337
|
+
|
|
338
|
+
const fogFar = new UINumber( 50 ).setWidth( '40px' ).setRange( 0, Infinity ).onChange( onFogSettingsChanged );
|
|
339
|
+
fogPropertiesRow.add( fogFar );
|
|
340
|
+
|
|
341
|
+
// fog density
|
|
342
|
+
|
|
343
|
+
const fogDensity = new UINumber( 0.05 ).setWidth( '40px' ).setRange( 0, 0.1 ).setStep( 0.001 ).setPrecision( 3 ).onChange( onFogSettingsChanged );
|
|
344
|
+
fogPropertiesRow.add( fogDensity );
|
|
345
|
+
|
|
346
|
+
//
|
|
347
|
+
|
|
348
|
+
function refreshUI() {
|
|
349
|
+
|
|
350
|
+
const camera = editor.camera;
|
|
351
|
+
const scene = editor.scene;
|
|
352
|
+
|
|
353
|
+
const options = [];
|
|
354
|
+
|
|
355
|
+
options.push( buildOption( camera, false ) );
|
|
356
|
+
options.push( buildOption( scene, false ) );
|
|
357
|
+
|
|
358
|
+
( function addObjects( objects, pad ) {
|
|
359
|
+
|
|
360
|
+
for ( let i = 0, l = objects.length; i < l; i ++ ) {
|
|
361
|
+
|
|
362
|
+
const object = objects[ i ];
|
|
363
|
+
|
|
364
|
+
if ( nodeStates.has( object ) === false ) {
|
|
365
|
+
|
|
366
|
+
nodeStates.set( object, false );
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const option = buildOption( object, true );
|
|
371
|
+
option.style.paddingLeft = ( pad * 18 ) + 'px';
|
|
372
|
+
options.push( option );
|
|
373
|
+
|
|
374
|
+
if ( nodeStates.get( object ) === true ) {
|
|
375
|
+
|
|
376
|
+
addObjects( object.children, pad + 1 );
|
|
377
|
+
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
} )( scene.children, 0 );
|
|
383
|
+
|
|
384
|
+
outliner.setOptions( options );
|
|
385
|
+
|
|
386
|
+
if ( editor.selected !== null ) {
|
|
387
|
+
|
|
388
|
+
outliner.setValue( editor.selected.id );
|
|
389
|
+
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if ( scene.background ) {
|
|
393
|
+
|
|
394
|
+
if ( scene.background.isColor ) {
|
|
395
|
+
|
|
396
|
+
backgroundType.setValue( 'Color' );
|
|
397
|
+
backgroundColor.setHexValue( scene.background.getHex() );
|
|
398
|
+
|
|
399
|
+
} else if ( scene.background.isTexture ) {
|
|
400
|
+
|
|
401
|
+
if ( scene.background.mapping === THREE.EquirectangularReflectionMapping ) {
|
|
402
|
+
|
|
403
|
+
backgroundType.setValue( 'Equirectangular' );
|
|
404
|
+
backgroundEquirectangularTexture.setValue( scene.background );
|
|
405
|
+
backgroundBlurriness.setValue( scene.backgroundBlurriness );
|
|
406
|
+
backgroundIntensity.setValue( scene.backgroundIntensity );
|
|
407
|
+
|
|
408
|
+
} else {
|
|
409
|
+
|
|
410
|
+
backgroundType.setValue( 'Texture' );
|
|
411
|
+
backgroundTexture.setValue( scene.background );
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
} else {
|
|
418
|
+
|
|
419
|
+
backgroundType.setValue( 'None' );
|
|
420
|
+
backgroundTexture.setValue( null );
|
|
421
|
+
backgroundEquirectangularTexture.setValue( null );
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if ( scene.environment ) {
|
|
426
|
+
|
|
427
|
+
if ( scene.background && scene.background.isTexture && scene.background.uuid === scene.environment.uuid ) {
|
|
428
|
+
|
|
429
|
+
environmentType.setValue( 'Background' );
|
|
430
|
+
|
|
431
|
+
} else if ( scene.environment.mapping === THREE.EquirectangularReflectionMapping ) {
|
|
432
|
+
|
|
433
|
+
environmentType.setValue( 'Equirectangular' );
|
|
434
|
+
environmentEquirectangularTexture.setValue( scene.environment );
|
|
435
|
+
|
|
436
|
+
} else if ( scene.environment.isRenderTargetTexture === true ) {
|
|
437
|
+
|
|
438
|
+
environmentType.setValue( 'ModelViewer' );
|
|
439
|
+
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
} else {
|
|
443
|
+
|
|
444
|
+
environmentType.setValue( 'None' );
|
|
445
|
+
environmentEquirectangularTexture.setValue( null );
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if ( scene.fog ) {
|
|
450
|
+
|
|
451
|
+
fogColor.setHexValue( scene.fog.color.getHex() );
|
|
452
|
+
|
|
453
|
+
if ( scene.fog.isFog ) {
|
|
454
|
+
|
|
455
|
+
fogType.setValue( 'Fog' );
|
|
456
|
+
fogNear.setValue( scene.fog.near );
|
|
457
|
+
fogFar.setValue( scene.fog.far );
|
|
458
|
+
|
|
459
|
+
} else if ( scene.fog.isFogExp2 ) {
|
|
460
|
+
|
|
461
|
+
fogType.setValue( 'FogExp2' );
|
|
462
|
+
fogDensity.setValue( scene.fog.density );
|
|
463
|
+
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
} else {
|
|
467
|
+
|
|
468
|
+
fogType.setValue( 'None' );
|
|
469
|
+
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
refreshBackgroundUI();
|
|
473
|
+
refreshEnvironmentUI();
|
|
474
|
+
refreshFogUI();
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function refreshFogUI() {
|
|
479
|
+
|
|
480
|
+
const type = fogType.getValue();
|
|
481
|
+
|
|
482
|
+
fogPropertiesRow.setDisplay( type === 'None' ? 'none' : '' );
|
|
483
|
+
fogNear.setDisplay( type === 'Fog' ? '' : 'none' );
|
|
484
|
+
fogFar.setDisplay( type === 'Fog' ? '' : 'none' );
|
|
485
|
+
fogDensity.setDisplay( type === 'FogExp2' ? '' : 'none' );
|
|
486
|
+
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
refreshUI();
|
|
490
|
+
|
|
491
|
+
// events
|
|
492
|
+
|
|
493
|
+
signals.editorCleared.add( refreshUI );
|
|
494
|
+
|
|
495
|
+
signals.sceneGraphChanged.add( refreshUI );
|
|
496
|
+
|
|
497
|
+
signals.refreshSidebarEnvironment.add( refreshUI );
|
|
498
|
+
|
|
499
|
+
signals.objectChanged.add( function ( object ) {
|
|
500
|
+
|
|
501
|
+
const options = outliner.options;
|
|
502
|
+
|
|
503
|
+
for ( let i = 0; i < options.length; i ++ ) {
|
|
504
|
+
|
|
505
|
+
const option = options[ i ];
|
|
506
|
+
|
|
507
|
+
if ( option.value === object.id ) {
|
|
508
|
+
|
|
509
|
+
const openerElement = option.querySelector( ':scope > .opener' );
|
|
510
|
+
|
|
511
|
+
const openerHTML = openerElement ? openerElement.outerHTML : '';
|
|
512
|
+
|
|
513
|
+
option.innerHTML = openerHTML + buildHTML( object );
|
|
514
|
+
|
|
515
|
+
return;
|
|
516
|
+
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
} );
|
|
522
|
+
|
|
523
|
+
signals.scriptAdded.add( function () {
|
|
524
|
+
|
|
525
|
+
if ( editor.selected !== null ) signals.objectChanged.dispatch( editor.selected );
|
|
526
|
+
|
|
527
|
+
} );
|
|
528
|
+
|
|
529
|
+
signals.scriptRemoved.add( function () {
|
|
530
|
+
|
|
531
|
+
if ( editor.selected !== null ) signals.objectChanged.dispatch( editor.selected );
|
|
532
|
+
|
|
533
|
+
} );
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
signals.objectSelected.add( function ( object ) {
|
|
537
|
+
|
|
538
|
+
if ( ignoreObjectSelectedSignal === true ) return;
|
|
539
|
+
|
|
540
|
+
if ( object !== null && object.parent !== null ) {
|
|
541
|
+
|
|
542
|
+
let needsRefresh = false;
|
|
543
|
+
let parent = object.parent;
|
|
544
|
+
|
|
545
|
+
while ( parent !== editor.scene ) {
|
|
546
|
+
|
|
547
|
+
if ( nodeStates.get( parent ) !== true ) {
|
|
548
|
+
|
|
549
|
+
nodeStates.set( parent, true );
|
|
550
|
+
needsRefresh = true;
|
|
551
|
+
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
parent = parent.parent;
|
|
555
|
+
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if ( needsRefresh ) refreshUI();
|
|
559
|
+
|
|
560
|
+
outliner.setValue( object.id );
|
|
561
|
+
|
|
562
|
+
} else {
|
|
563
|
+
|
|
564
|
+
outliner.setValue( null );
|
|
565
|
+
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
} );
|
|
569
|
+
|
|
570
|
+
signals.sceneBackgroundChanged.add( function () {
|
|
571
|
+
|
|
572
|
+
if ( environmentType.getValue() === 'Background' ) {
|
|
573
|
+
|
|
574
|
+
onEnvironmentChanged();
|
|
575
|
+
refreshEnvironmentUI();
|
|
576
|
+
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
} );
|
|
580
|
+
|
|
581
|
+
return container;
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
export { SidebarScene };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { UIPanel, UIBreak, UIButton, UIRow, UIInput } from './libs/ui.js';
|
|
2
|
+
|
|
3
|
+
import { AddScriptCommand } from './commands/AddScriptCommand.js';
|
|
4
|
+
import { SetScriptValueCommand } from './commands/SetScriptValueCommand.js';
|
|
5
|
+
import { RemoveScriptCommand } from './commands/RemoveScriptCommand.js';
|
|
6
|
+
|
|
7
|
+
function SidebarScript( editor ) {
|
|
8
|
+
|
|
9
|
+
const strings = editor.strings;
|
|
10
|
+
|
|
11
|
+
const signals = editor.signals;
|
|
12
|
+
|
|
13
|
+
const container = new UIPanel();
|
|
14
|
+
container.setBorderTop( '0' );
|
|
15
|
+
container.setPaddingTop( '20px' );
|
|
16
|
+
container.setDisplay( 'none' );
|
|
17
|
+
|
|
18
|
+
//
|
|
19
|
+
|
|
20
|
+
const scriptsContainer = new UIRow();
|
|
21
|
+
container.add( scriptsContainer );
|
|
22
|
+
|
|
23
|
+
const newScript = new UIButton( strings.getKey( 'sidebar/script/new' ) );
|
|
24
|
+
newScript.onClick( function () {
|
|
25
|
+
|
|
26
|
+
const script = { name: '', source: 'function update( event ) {}' };
|
|
27
|
+
editor.execute( new AddScriptCommand( editor, editor.selected, script ) );
|
|
28
|
+
|
|
29
|
+
} );
|
|
30
|
+
container.add( newScript );
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
let loadScript = new UI.Button( 'Load' );
|
|
34
|
+
loadScript.setMarginLeft( '4px' );
|
|
35
|
+
container.add( loadScript );
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
//
|
|
39
|
+
|
|
40
|
+
function update() {
|
|
41
|
+
|
|
42
|
+
scriptsContainer.clear();
|
|
43
|
+
scriptsContainer.setDisplay( 'none' );
|
|
44
|
+
|
|
45
|
+
const object = editor.selected;
|
|
46
|
+
|
|
47
|
+
if ( object === null ) {
|
|
48
|
+
|
|
49
|
+
return;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const scripts = editor.scripts[ object.uuid ];
|
|
54
|
+
|
|
55
|
+
if ( scripts !== undefined && scripts.length > 0 ) {
|
|
56
|
+
|
|
57
|
+
scriptsContainer.setDisplay( 'block' );
|
|
58
|
+
|
|
59
|
+
for ( let i = 0; i < scripts.length; i ++ ) {
|
|
60
|
+
|
|
61
|
+
( function ( object, script ) {
|
|
62
|
+
|
|
63
|
+
const name = new UIInput( script.name ).setWidth( '130px' ).setFontSize( '12px' );
|
|
64
|
+
name.onChange( function () {
|
|
65
|
+
|
|
66
|
+
editor.execute( new SetScriptValueCommand( editor, editor.selected, script, 'name', this.getValue() ) );
|
|
67
|
+
|
|
68
|
+
} );
|
|
69
|
+
scriptsContainer.add( name );
|
|
70
|
+
|
|
71
|
+
const edit = new UIButton( strings.getKey( 'sidebar/script/edit' ) );
|
|
72
|
+
edit.setMarginLeft( '4px' );
|
|
73
|
+
edit.onClick( function () {
|
|
74
|
+
|
|
75
|
+
signals.editScript.dispatch( object, script );
|
|
76
|
+
|
|
77
|
+
} );
|
|
78
|
+
scriptsContainer.add( edit );
|
|
79
|
+
|
|
80
|
+
const remove = new UIButton( strings.getKey( 'sidebar/script/remove' ) );
|
|
81
|
+
remove.setMarginLeft( '4px' );
|
|
82
|
+
remove.onClick( function () {
|
|
83
|
+
|
|
84
|
+
if ( confirm( strings.getKey( 'prompt/script/remove' ) ) ) {
|
|
85
|
+
|
|
86
|
+
editor.execute( new RemoveScriptCommand( editor, editor.selected, script ) );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
} );
|
|
91
|
+
scriptsContainer.add( remove );
|
|
92
|
+
|
|
93
|
+
scriptsContainer.add( new UIBreak() );
|
|
94
|
+
|
|
95
|
+
} )( object, scripts[ i ] );
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// signals
|
|
104
|
+
|
|
105
|
+
signals.objectSelected.add( function ( object ) {
|
|
106
|
+
|
|
107
|
+
if ( object !== null && editor.camera !== object ) {
|
|
108
|
+
|
|
109
|
+
container.setDisplay( 'block' );
|
|
110
|
+
|
|
111
|
+
update();
|
|
112
|
+
|
|
113
|
+
} else {
|
|
114
|
+
|
|
115
|
+
container.setDisplay( 'none' );
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
} );
|
|
120
|
+
|
|
121
|
+
signals.scriptAdded.add( update );
|
|
122
|
+
signals.scriptRemoved.add( update );
|
|
123
|
+
signals.scriptChanged.add( update );
|
|
124
|
+
|
|
125
|
+
return container;
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { SidebarScript };
|