spoint 0.1.0 → 0.1.11
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 +31 -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,898 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
|
|
3
|
+
import { UIPanel, UIRow, UIInput, UIButton, UIColor, UICheckbox, UIInteger, UITextArea, UIText, UINumber } from './libs/ui.js';
|
|
4
|
+
import { UIBoolean } from './libs/ui.three.js';
|
|
5
|
+
|
|
6
|
+
import { SetUuidCommand } from './commands/SetUuidCommand.js';
|
|
7
|
+
import { SetValueCommand } from './commands/SetValueCommand.js';
|
|
8
|
+
import { SetPositionCommand } from './commands/SetPositionCommand.js';
|
|
9
|
+
import { SetRotationCommand } from './commands/SetRotationCommand.js';
|
|
10
|
+
import { SetScaleCommand } from './commands/SetScaleCommand.js';
|
|
11
|
+
import { SetColorCommand } from './commands/SetColorCommand.js';
|
|
12
|
+
import { SetShadowValueCommand } from './commands/SetShadowValueCommand.js';
|
|
13
|
+
|
|
14
|
+
import { SidebarObjectAnimation } from './Sidebar.Object.Animation.js';
|
|
15
|
+
|
|
16
|
+
function SidebarObject( editor ) {
|
|
17
|
+
|
|
18
|
+
const strings = editor.strings;
|
|
19
|
+
|
|
20
|
+
const signals = editor.signals;
|
|
21
|
+
|
|
22
|
+
const container = new UIPanel();
|
|
23
|
+
container.setBorderTop( '0' );
|
|
24
|
+
container.setPaddingTop( '20px' );
|
|
25
|
+
container.setDisplay( 'none' );
|
|
26
|
+
|
|
27
|
+
// Actions
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
let objectActions = new UI.Select().setPosition( 'absolute' ).setRight( '8px' ).setFontSize( '11px' );
|
|
31
|
+
objectActions.setOptions( {
|
|
32
|
+
|
|
33
|
+
'Actions': 'Actions',
|
|
34
|
+
'Reset Position': 'Reset Position',
|
|
35
|
+
'Reset Rotation': 'Reset Rotation',
|
|
36
|
+
'Reset Scale': 'Reset Scale'
|
|
37
|
+
|
|
38
|
+
} );
|
|
39
|
+
objectActions.onClick( function ( event ) {
|
|
40
|
+
|
|
41
|
+
event.stopPropagation(); // Avoid panel collapsing
|
|
42
|
+
|
|
43
|
+
} );
|
|
44
|
+
objectActions.onChange( function ( event ) {
|
|
45
|
+
|
|
46
|
+
let object = editor.selected;
|
|
47
|
+
|
|
48
|
+
switch ( this.getValue() ) {
|
|
49
|
+
|
|
50
|
+
case 'Reset Position':
|
|
51
|
+
editor.execute( new SetPositionCommand( editor, object, new Vector3( 0, 0, 0 ) ) );
|
|
52
|
+
break;
|
|
53
|
+
|
|
54
|
+
case 'Reset Rotation':
|
|
55
|
+
editor.execute( new SetRotationCommand( editor, object, new Euler( 0, 0, 0 ) ) );
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case 'Reset Scale':
|
|
59
|
+
editor.execute( new SetScaleCommand( editor, object, new Vector3( 1, 1, 1 ) ) );
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.setValue( 'Actions' );
|
|
65
|
+
|
|
66
|
+
} );
|
|
67
|
+
container.addStatic( objectActions );
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
// type
|
|
71
|
+
|
|
72
|
+
const objectTypeRow = new UIRow();
|
|
73
|
+
const objectType = new UIText();
|
|
74
|
+
|
|
75
|
+
objectTypeRow.add( new UIText( strings.getKey( 'sidebar/object/type' ) ).setClass( 'Label' ) );
|
|
76
|
+
objectTypeRow.add( objectType );
|
|
77
|
+
|
|
78
|
+
container.add( objectTypeRow );
|
|
79
|
+
|
|
80
|
+
// uuid
|
|
81
|
+
|
|
82
|
+
const objectUUIDRow = new UIRow();
|
|
83
|
+
const objectUUID = new UIInput().setWidth( '102px' ).setFontSize( '12px' ).setDisabled( true );
|
|
84
|
+
const objectUUIDRenew = new UIButton( strings.getKey( 'sidebar/object/new' ) ).setMarginLeft( '7px' ).onClick( function () {
|
|
85
|
+
|
|
86
|
+
objectUUID.setValue( THREE.MathUtils.generateUUID() );
|
|
87
|
+
|
|
88
|
+
editor.execute( new SetUuidCommand( editor, editor.selected, objectUUID.getValue() ) );
|
|
89
|
+
|
|
90
|
+
} );
|
|
91
|
+
|
|
92
|
+
objectUUIDRow.add( new UIText( strings.getKey( 'sidebar/object/uuid' ) ).setClass( 'Label' ) );
|
|
93
|
+
objectUUIDRow.add( objectUUID );
|
|
94
|
+
objectUUIDRow.add( objectUUIDRenew );
|
|
95
|
+
|
|
96
|
+
container.add( objectUUIDRow );
|
|
97
|
+
|
|
98
|
+
// name
|
|
99
|
+
|
|
100
|
+
const objectNameRow = new UIRow();
|
|
101
|
+
const objectName = new UIInput().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
|
|
102
|
+
|
|
103
|
+
editor.execute( new SetValueCommand( editor, editor.selected, 'name', objectName.getValue() ) );
|
|
104
|
+
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
objectNameRow.add( new UIText( strings.getKey( 'sidebar/object/name' ) ).setClass( 'Label' ) );
|
|
108
|
+
objectNameRow.add( objectName );
|
|
109
|
+
|
|
110
|
+
container.add( objectNameRow );
|
|
111
|
+
|
|
112
|
+
// position
|
|
113
|
+
|
|
114
|
+
const objectPositionRow = new UIRow();
|
|
115
|
+
const objectPositionX = new UINumber().setPrecision( 3 ).setWidth( '50px' ).onChange( update );
|
|
116
|
+
const objectPositionY = new UINumber().setPrecision( 3 ).setWidth( '50px' ).onChange( update );
|
|
117
|
+
const objectPositionZ = new UINumber().setPrecision( 3 ).setWidth( '50px' ).onChange( update );
|
|
118
|
+
|
|
119
|
+
objectPositionRow.add( new UIText( strings.getKey( 'sidebar/object/position' ) ).setClass( 'Label' ) );
|
|
120
|
+
objectPositionRow.add( objectPositionX, objectPositionY, objectPositionZ );
|
|
121
|
+
|
|
122
|
+
container.add( objectPositionRow );
|
|
123
|
+
|
|
124
|
+
// rotation
|
|
125
|
+
|
|
126
|
+
const objectRotationRow = new UIRow();
|
|
127
|
+
const objectRotationX = new UINumber().setStep( 10 ).setNudge( 0.1 ).setUnit( '°' ).setWidth( '50px' ).onChange( update );
|
|
128
|
+
const objectRotationY = new UINumber().setStep( 10 ).setNudge( 0.1 ).setUnit( '°' ).setWidth( '50px' ).onChange( update );
|
|
129
|
+
const objectRotationZ = new UINumber().setStep( 10 ).setNudge( 0.1 ).setUnit( '°' ).setWidth( '50px' ).onChange( update );
|
|
130
|
+
|
|
131
|
+
objectRotationRow.add( new UIText( strings.getKey( 'sidebar/object/rotation' ) ).setClass( 'Label' ) );
|
|
132
|
+
objectRotationRow.add( objectRotationX, objectRotationY, objectRotationZ );
|
|
133
|
+
|
|
134
|
+
container.add( objectRotationRow );
|
|
135
|
+
|
|
136
|
+
// scale
|
|
137
|
+
|
|
138
|
+
const objectScaleRow = new UIRow();
|
|
139
|
+
const objectScaleX = new UINumber( 1 ).setPrecision( 3 ).setWidth( '50px' ).onChange( update );
|
|
140
|
+
const objectScaleY = new UINumber( 1 ).setPrecision( 3 ).setWidth( '50px' ).onChange( update );
|
|
141
|
+
const objectScaleZ = new UINumber( 1 ).setPrecision( 3 ).setWidth( '50px' ).onChange( update );
|
|
142
|
+
|
|
143
|
+
objectScaleRow.add( new UIText( strings.getKey( 'sidebar/object/scale' ) ).setClass( 'Label' ) );
|
|
144
|
+
objectScaleRow.add( objectScaleX, objectScaleY, objectScaleZ );
|
|
145
|
+
|
|
146
|
+
container.add( objectScaleRow );
|
|
147
|
+
|
|
148
|
+
// fov
|
|
149
|
+
|
|
150
|
+
const objectFovRow = new UIRow();
|
|
151
|
+
const objectFov = new UINumber().onChange( update );
|
|
152
|
+
|
|
153
|
+
objectFovRow.add( new UIText( strings.getKey( 'sidebar/object/fov' ) ).setClass( 'Label' ) );
|
|
154
|
+
objectFovRow.add( objectFov );
|
|
155
|
+
|
|
156
|
+
container.add( objectFovRow );
|
|
157
|
+
|
|
158
|
+
// left
|
|
159
|
+
|
|
160
|
+
const objectLeftRow = new UIRow();
|
|
161
|
+
const objectLeft = new UINumber().onChange( update );
|
|
162
|
+
|
|
163
|
+
objectLeftRow.add( new UIText( strings.getKey( 'sidebar/object/left' ) ).setClass( 'Label' ) );
|
|
164
|
+
objectLeftRow.add( objectLeft );
|
|
165
|
+
|
|
166
|
+
container.add( objectLeftRow );
|
|
167
|
+
|
|
168
|
+
// right
|
|
169
|
+
|
|
170
|
+
const objectRightRow = new UIRow();
|
|
171
|
+
const objectRight = new UINumber().onChange( update );
|
|
172
|
+
|
|
173
|
+
objectRightRow.add( new UIText( strings.getKey( 'sidebar/object/right' ) ).setClass( 'Label' ) );
|
|
174
|
+
objectRightRow.add( objectRight );
|
|
175
|
+
|
|
176
|
+
container.add( objectRightRow );
|
|
177
|
+
|
|
178
|
+
// top
|
|
179
|
+
|
|
180
|
+
const objectTopRow = new UIRow();
|
|
181
|
+
const objectTop = new UINumber().onChange( update );
|
|
182
|
+
|
|
183
|
+
objectTopRow.add( new UIText( strings.getKey( 'sidebar/object/top' ) ).setClass( 'Label' ) );
|
|
184
|
+
objectTopRow.add( objectTop );
|
|
185
|
+
|
|
186
|
+
container.add( objectTopRow );
|
|
187
|
+
|
|
188
|
+
// bottom
|
|
189
|
+
|
|
190
|
+
const objectBottomRow = new UIRow();
|
|
191
|
+
const objectBottom = new UINumber().onChange( update );
|
|
192
|
+
|
|
193
|
+
objectBottomRow.add( new UIText( strings.getKey( 'sidebar/object/bottom' ) ).setClass( 'Label' ) );
|
|
194
|
+
objectBottomRow.add( objectBottom );
|
|
195
|
+
|
|
196
|
+
container.add( objectBottomRow );
|
|
197
|
+
|
|
198
|
+
// near
|
|
199
|
+
|
|
200
|
+
const objectNearRow = new UIRow();
|
|
201
|
+
const objectNear = new UINumber().onChange( update );
|
|
202
|
+
|
|
203
|
+
objectNearRow.add( new UIText( strings.getKey( 'sidebar/object/near' ) ).setClass( 'Label' ) );
|
|
204
|
+
objectNearRow.add( objectNear );
|
|
205
|
+
|
|
206
|
+
container.add( objectNearRow );
|
|
207
|
+
|
|
208
|
+
// far
|
|
209
|
+
|
|
210
|
+
const objectFarRow = new UIRow();
|
|
211
|
+
const objectFar = new UINumber().onChange( update );
|
|
212
|
+
|
|
213
|
+
objectFarRow.add( new UIText( strings.getKey( 'sidebar/object/far' ) ).setClass( 'Label' ) );
|
|
214
|
+
objectFarRow.add( objectFar );
|
|
215
|
+
|
|
216
|
+
container.add( objectFarRow );
|
|
217
|
+
|
|
218
|
+
// intensity
|
|
219
|
+
|
|
220
|
+
const objectIntensityRow = new UIRow();
|
|
221
|
+
const objectIntensity = new UINumber().onChange( update );
|
|
222
|
+
|
|
223
|
+
objectIntensityRow.add( new UIText( strings.getKey( 'sidebar/object/intensity' ) ).setClass( 'Label' ) );
|
|
224
|
+
objectIntensityRow.add( objectIntensity );
|
|
225
|
+
|
|
226
|
+
container.add( objectIntensityRow );
|
|
227
|
+
|
|
228
|
+
// color
|
|
229
|
+
|
|
230
|
+
const objectColorRow = new UIRow();
|
|
231
|
+
const objectColor = new UIColor().onInput( update );
|
|
232
|
+
|
|
233
|
+
objectColorRow.add( new UIText( strings.getKey( 'sidebar/object/color' ) ).setClass( 'Label' ) );
|
|
234
|
+
objectColorRow.add( objectColor );
|
|
235
|
+
|
|
236
|
+
container.add( objectColorRow );
|
|
237
|
+
|
|
238
|
+
// ground color
|
|
239
|
+
|
|
240
|
+
const objectGroundColorRow = new UIRow();
|
|
241
|
+
const objectGroundColor = new UIColor().onInput( update );
|
|
242
|
+
|
|
243
|
+
objectGroundColorRow.add( new UIText( strings.getKey( 'sidebar/object/groundcolor' ) ).setClass( 'Label' ) );
|
|
244
|
+
objectGroundColorRow.add( objectGroundColor );
|
|
245
|
+
|
|
246
|
+
container.add( objectGroundColorRow );
|
|
247
|
+
|
|
248
|
+
// distance
|
|
249
|
+
|
|
250
|
+
const objectDistanceRow = new UIRow();
|
|
251
|
+
const objectDistance = new UINumber().setRange( 0, Infinity ).onChange( update );
|
|
252
|
+
|
|
253
|
+
objectDistanceRow.add( new UIText( strings.getKey( 'sidebar/object/distance' ) ).setClass( 'Label' ) );
|
|
254
|
+
objectDistanceRow.add( objectDistance );
|
|
255
|
+
|
|
256
|
+
container.add( objectDistanceRow );
|
|
257
|
+
|
|
258
|
+
// angle
|
|
259
|
+
|
|
260
|
+
const objectAngleRow = new UIRow();
|
|
261
|
+
const objectAngle = new UINumber().setPrecision( 3 ).setRange( 0, Math.PI / 2 ).onChange( update );
|
|
262
|
+
|
|
263
|
+
objectAngleRow.add( new UIText( strings.getKey( 'sidebar/object/angle' ) ).setClass( 'Label' ) );
|
|
264
|
+
objectAngleRow.add( objectAngle );
|
|
265
|
+
|
|
266
|
+
container.add( objectAngleRow );
|
|
267
|
+
|
|
268
|
+
// penumbra
|
|
269
|
+
|
|
270
|
+
const objectPenumbraRow = new UIRow();
|
|
271
|
+
const objectPenumbra = new UINumber().setRange( 0, 1 ).onChange( update );
|
|
272
|
+
|
|
273
|
+
objectPenumbraRow.add( new UIText( strings.getKey( 'sidebar/object/penumbra' ) ).setClass( 'Label' ) );
|
|
274
|
+
objectPenumbraRow.add( objectPenumbra );
|
|
275
|
+
|
|
276
|
+
container.add( objectPenumbraRow );
|
|
277
|
+
|
|
278
|
+
// decay
|
|
279
|
+
|
|
280
|
+
const objectDecayRow = new UIRow();
|
|
281
|
+
const objectDecay = new UINumber().setRange( 0, Infinity ).onChange( update );
|
|
282
|
+
|
|
283
|
+
objectDecayRow.add( new UIText( strings.getKey( 'sidebar/object/decay' ) ).setClass( 'Label' ) );
|
|
284
|
+
objectDecayRow.add( objectDecay );
|
|
285
|
+
|
|
286
|
+
container.add( objectDecayRow );
|
|
287
|
+
|
|
288
|
+
// shadow
|
|
289
|
+
|
|
290
|
+
const objectShadowRow = new UIRow();
|
|
291
|
+
|
|
292
|
+
objectShadowRow.add( new UIText( strings.getKey( 'sidebar/object/shadow' ) ).setClass( 'Label' ) );
|
|
293
|
+
|
|
294
|
+
const objectCastShadow = new UIBoolean( false, strings.getKey( 'sidebar/object/cast' ) ).onChange( update );
|
|
295
|
+
objectShadowRow.add( objectCastShadow );
|
|
296
|
+
|
|
297
|
+
const objectReceiveShadow = new UIBoolean( false, strings.getKey( 'sidebar/object/receive' ) ).onChange( update );
|
|
298
|
+
objectShadowRow.add( objectReceiveShadow );
|
|
299
|
+
|
|
300
|
+
container.add( objectShadowRow );
|
|
301
|
+
|
|
302
|
+
// shadow intensity
|
|
303
|
+
|
|
304
|
+
const objectShadowIntensityRow = new UIRow();
|
|
305
|
+
|
|
306
|
+
objectShadowIntensityRow.add( new UIText( strings.getKey( 'sidebar/object/shadowIntensity' ) ).setClass( 'Label' ) );
|
|
307
|
+
|
|
308
|
+
const objectShadowIntensity = new UINumber( 0 ).setRange( 0, 1 ).onChange( update );
|
|
309
|
+
objectShadowIntensityRow.add( objectShadowIntensity );
|
|
310
|
+
|
|
311
|
+
container.add( objectShadowIntensityRow );
|
|
312
|
+
|
|
313
|
+
// shadow bias
|
|
314
|
+
|
|
315
|
+
const objectShadowBiasRow = new UIRow();
|
|
316
|
+
|
|
317
|
+
objectShadowBiasRow.add( new UIText( strings.getKey( 'sidebar/object/shadowBias' ) ).setClass( 'Label' ) );
|
|
318
|
+
|
|
319
|
+
const objectShadowBias = new UINumber( 0 ).setPrecision( 5 ).setStep( 0.0001 ).setNudge( 0.00001 ).onChange( update );
|
|
320
|
+
objectShadowBiasRow.add( objectShadowBias );
|
|
321
|
+
|
|
322
|
+
container.add( objectShadowBiasRow );
|
|
323
|
+
|
|
324
|
+
// shadow normal offset
|
|
325
|
+
|
|
326
|
+
const objectShadowNormalBiasRow = new UIRow();
|
|
327
|
+
|
|
328
|
+
objectShadowNormalBiasRow.add( new UIText( strings.getKey( 'sidebar/object/shadowNormalBias' ) ).setClass( 'Label' ) );
|
|
329
|
+
|
|
330
|
+
const objectShadowNormalBias = new UINumber( 0 ).onChange( update );
|
|
331
|
+
objectShadowNormalBiasRow.add( objectShadowNormalBias );
|
|
332
|
+
|
|
333
|
+
container.add( objectShadowNormalBiasRow );
|
|
334
|
+
|
|
335
|
+
// shadow radius
|
|
336
|
+
|
|
337
|
+
const objectShadowRadiusRow = new UIRow();
|
|
338
|
+
|
|
339
|
+
objectShadowRadiusRow.add( new UIText( strings.getKey( 'sidebar/object/shadowRadius' ) ).setClass( 'Label' ) );
|
|
340
|
+
|
|
341
|
+
const objectShadowRadius = new UINumber( 1 ).onChange( update );
|
|
342
|
+
objectShadowRadiusRow.add( objectShadowRadius );
|
|
343
|
+
|
|
344
|
+
container.add( objectShadowRadiusRow );
|
|
345
|
+
|
|
346
|
+
// visible
|
|
347
|
+
|
|
348
|
+
const objectVisibleRow = new UIRow();
|
|
349
|
+
const objectVisible = new UICheckbox().onChange( update );
|
|
350
|
+
|
|
351
|
+
objectVisibleRow.add( new UIText( strings.getKey( 'sidebar/object/visible' ) ).setClass( 'Label' ) );
|
|
352
|
+
objectVisibleRow.add( objectVisible );
|
|
353
|
+
|
|
354
|
+
container.add( objectVisibleRow );
|
|
355
|
+
|
|
356
|
+
// frustumCulled
|
|
357
|
+
|
|
358
|
+
const objectFrustumCulledRow = new UIRow();
|
|
359
|
+
const objectFrustumCulled = new UICheckbox().onChange( update );
|
|
360
|
+
|
|
361
|
+
objectFrustumCulledRow.add( new UIText( strings.getKey( 'sidebar/object/frustumcull' ) ).setClass( 'Label' ) );
|
|
362
|
+
objectFrustumCulledRow.add( objectFrustumCulled );
|
|
363
|
+
|
|
364
|
+
container.add( objectFrustumCulledRow );
|
|
365
|
+
|
|
366
|
+
// renderOrder
|
|
367
|
+
|
|
368
|
+
const objectRenderOrderRow = new UIRow();
|
|
369
|
+
const objectRenderOrder = new UIInteger().setWidth( '50px' ).onChange( update );
|
|
370
|
+
|
|
371
|
+
objectRenderOrderRow.add( new UIText( strings.getKey( 'sidebar/object/renderorder' ) ).setClass( 'Label' ) );
|
|
372
|
+
objectRenderOrderRow.add( objectRenderOrder );
|
|
373
|
+
|
|
374
|
+
container.add( objectRenderOrderRow );
|
|
375
|
+
|
|
376
|
+
// user data
|
|
377
|
+
|
|
378
|
+
const objectUserDataRow = new UIRow();
|
|
379
|
+
const objectUserData = new UITextArea().setWidth( '150px' ).setHeight( '40px' ).setFontSize( '12px' ).onChange( update );
|
|
380
|
+
objectUserData.onKeyUp( function () {
|
|
381
|
+
|
|
382
|
+
try {
|
|
383
|
+
|
|
384
|
+
JSON.parse( objectUserData.getValue() );
|
|
385
|
+
|
|
386
|
+
objectUserData.dom.classList.add( 'success' );
|
|
387
|
+
objectUserData.dom.classList.remove( 'fail' );
|
|
388
|
+
|
|
389
|
+
} catch ( error ) {
|
|
390
|
+
|
|
391
|
+
objectUserData.dom.classList.remove( 'success' );
|
|
392
|
+
objectUserData.dom.classList.add( 'fail' );
|
|
393
|
+
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
} );
|
|
397
|
+
|
|
398
|
+
objectUserDataRow.add( new UIText( strings.getKey( 'sidebar/object/userdata' ) ).setClass( 'Label' ) );
|
|
399
|
+
objectUserDataRow.add( objectUserData );
|
|
400
|
+
|
|
401
|
+
container.add( objectUserDataRow );
|
|
402
|
+
|
|
403
|
+
// Export JSON
|
|
404
|
+
|
|
405
|
+
const exportJson = new UIButton( strings.getKey( 'sidebar/object/export' ) );
|
|
406
|
+
exportJson.setMarginLeft( '120px' );
|
|
407
|
+
exportJson.onClick( function () {
|
|
408
|
+
|
|
409
|
+
const object = editor.selected;
|
|
410
|
+
|
|
411
|
+
let output = object.toJSON();
|
|
412
|
+
|
|
413
|
+
try {
|
|
414
|
+
|
|
415
|
+
output = JSON.stringify( output, null, '\t' );
|
|
416
|
+
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
|
|
417
|
+
|
|
418
|
+
} catch ( e ) {
|
|
419
|
+
|
|
420
|
+
output = JSON.stringify( output );
|
|
421
|
+
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
editor.utils.save( new Blob( [ output ] ), `${ objectName.getValue() || 'object' }.json` );
|
|
426
|
+
|
|
427
|
+
} );
|
|
428
|
+
container.add( exportJson );
|
|
429
|
+
|
|
430
|
+
// Animations
|
|
431
|
+
|
|
432
|
+
container.add( new SidebarObjectAnimation( editor ) );
|
|
433
|
+
|
|
434
|
+
//
|
|
435
|
+
|
|
436
|
+
function update() {
|
|
437
|
+
|
|
438
|
+
const object = editor.selected;
|
|
439
|
+
|
|
440
|
+
if ( object !== null ) {
|
|
441
|
+
|
|
442
|
+
const newPosition = new THREE.Vector3( objectPositionX.getValue(), objectPositionY.getValue(), objectPositionZ.getValue() );
|
|
443
|
+
if ( object.position.distanceTo( newPosition ) >= 0.01 ) {
|
|
444
|
+
|
|
445
|
+
editor.execute( new SetPositionCommand( editor, object, newPosition ) );
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const newRotation = new THREE.Euler( objectRotationX.getValue() * THREE.MathUtils.DEG2RAD, objectRotationY.getValue() * THREE.MathUtils.DEG2RAD, objectRotationZ.getValue() * THREE.MathUtils.DEG2RAD );
|
|
450
|
+
if ( new THREE.Vector3().setFromEuler( object.rotation ).distanceTo( new THREE.Vector3().setFromEuler( newRotation ) ) >= 0.01 ) {
|
|
451
|
+
|
|
452
|
+
editor.execute( new SetRotationCommand( editor, object, newRotation ) );
|
|
453
|
+
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const newScale = new THREE.Vector3( objectScaleX.getValue(), objectScaleY.getValue(), objectScaleZ.getValue() );
|
|
457
|
+
if ( object.scale.distanceTo( newScale ) >= 0.01 ) {
|
|
458
|
+
|
|
459
|
+
editor.execute( new SetScaleCommand( editor, object, newScale ) );
|
|
460
|
+
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if ( object.fov !== undefined && Math.abs( object.fov - objectFov.getValue() ) >= 0.01 ) {
|
|
464
|
+
|
|
465
|
+
editor.execute( new SetValueCommand( editor, object, 'fov', objectFov.getValue() ) );
|
|
466
|
+
object.updateProjectionMatrix();
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if ( object.left !== undefined && Math.abs( object.left - objectLeft.getValue() ) >= 0.01 ) {
|
|
471
|
+
|
|
472
|
+
editor.execute( new SetValueCommand( editor, object, 'left', objectLeft.getValue() ) );
|
|
473
|
+
object.updateProjectionMatrix();
|
|
474
|
+
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if ( object.right !== undefined && Math.abs( object.right - objectRight.getValue() ) >= 0.01 ) {
|
|
478
|
+
|
|
479
|
+
editor.execute( new SetValueCommand( editor, object, 'right', objectRight.getValue() ) );
|
|
480
|
+
object.updateProjectionMatrix();
|
|
481
|
+
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if ( object.top !== undefined && Math.abs( object.top - objectTop.getValue() ) >= 0.01 ) {
|
|
485
|
+
|
|
486
|
+
editor.execute( new SetValueCommand( editor, object, 'top', objectTop.getValue() ) );
|
|
487
|
+
object.updateProjectionMatrix();
|
|
488
|
+
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if ( object.bottom !== undefined && Math.abs( object.bottom - objectBottom.getValue() ) >= 0.01 ) {
|
|
492
|
+
|
|
493
|
+
editor.execute( new SetValueCommand( editor, object, 'bottom', objectBottom.getValue() ) );
|
|
494
|
+
object.updateProjectionMatrix();
|
|
495
|
+
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if ( object.near !== undefined && Math.abs( object.near - objectNear.getValue() ) >= 0.01 ) {
|
|
499
|
+
|
|
500
|
+
editor.execute( new SetValueCommand( editor, object, 'near', objectNear.getValue() ) );
|
|
501
|
+
if ( object.isOrthographicCamera ) {
|
|
502
|
+
|
|
503
|
+
object.updateProjectionMatrix();
|
|
504
|
+
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if ( object.far !== undefined && Math.abs( object.far - objectFar.getValue() ) >= 0.01 ) {
|
|
510
|
+
|
|
511
|
+
editor.execute( new SetValueCommand( editor, object, 'far', objectFar.getValue() ) );
|
|
512
|
+
if ( object.isOrthographicCamera ) {
|
|
513
|
+
|
|
514
|
+
object.updateProjectionMatrix();
|
|
515
|
+
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if ( object.intensity !== undefined && Math.abs( object.intensity - objectIntensity.getValue() ) >= 0.01 ) {
|
|
521
|
+
|
|
522
|
+
editor.execute( new SetValueCommand( editor, object, 'intensity', objectIntensity.getValue() ) );
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if ( object.color !== undefined && object.color.getHex() !== objectColor.getHexValue() ) {
|
|
527
|
+
|
|
528
|
+
editor.execute( new SetColorCommand( editor, object, 'color', objectColor.getHexValue() ) );
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
if ( object.groundColor !== undefined && object.groundColor.getHex() !== objectGroundColor.getHexValue() ) {
|
|
533
|
+
|
|
534
|
+
editor.execute( new SetColorCommand( editor, object, 'groundColor', objectGroundColor.getHexValue() ) );
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if ( object.distance !== undefined && Math.abs( object.distance - objectDistance.getValue() ) >= 0.01 ) {
|
|
539
|
+
|
|
540
|
+
editor.execute( new SetValueCommand( editor, object, 'distance', objectDistance.getValue() ) );
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if ( object.angle !== undefined && Math.abs( object.angle - objectAngle.getValue() ) >= 0.01 ) {
|
|
545
|
+
|
|
546
|
+
editor.execute( new SetValueCommand( editor, object, 'angle', objectAngle.getValue() ) );
|
|
547
|
+
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if ( object.penumbra !== undefined && Math.abs( object.penumbra - objectPenumbra.getValue() ) >= 0.01 ) {
|
|
551
|
+
|
|
552
|
+
editor.execute( new SetValueCommand( editor, object, 'penumbra', objectPenumbra.getValue() ) );
|
|
553
|
+
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if ( object.decay !== undefined && Math.abs( object.decay - objectDecay.getValue() ) >= 0.01 ) {
|
|
557
|
+
|
|
558
|
+
editor.execute( new SetValueCommand( editor, object, 'decay', objectDecay.getValue() ) );
|
|
559
|
+
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if ( object.visible !== objectVisible.getValue() ) {
|
|
563
|
+
|
|
564
|
+
editor.execute( new SetValueCommand( editor, object, 'visible', objectVisible.getValue() ) );
|
|
565
|
+
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if ( object.frustumCulled !== objectFrustumCulled.getValue() ) {
|
|
569
|
+
|
|
570
|
+
editor.execute( new SetValueCommand( editor, object, 'frustumCulled', objectFrustumCulled.getValue() ) );
|
|
571
|
+
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if ( object.renderOrder !== objectRenderOrder.getValue() ) {
|
|
575
|
+
|
|
576
|
+
editor.execute( new SetValueCommand( editor, object, 'renderOrder', objectRenderOrder.getValue() ) );
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if ( object.castShadow !== undefined && object.castShadow !== objectCastShadow.getValue() ) {
|
|
581
|
+
|
|
582
|
+
editor.execute( new SetValueCommand( editor, object, 'castShadow', objectCastShadow.getValue() ) );
|
|
583
|
+
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if ( object.receiveShadow !== objectReceiveShadow.getValue() ) {
|
|
587
|
+
|
|
588
|
+
if ( object.material !== undefined ) object.material.needsUpdate = true;
|
|
589
|
+
editor.execute( new SetValueCommand( editor, object, 'receiveShadow', objectReceiveShadow.getValue() ) );
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if ( object.shadow !== undefined ) {
|
|
594
|
+
|
|
595
|
+
if ( object.shadow.intensity !== objectShadowIntensity.getValue() ) {
|
|
596
|
+
|
|
597
|
+
editor.execute( new SetShadowValueCommand( editor, object, 'intensity', objectShadowIntensity.getValue() ) );
|
|
598
|
+
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if ( object.shadow.bias !== objectShadowBias.getValue() ) {
|
|
602
|
+
|
|
603
|
+
editor.execute( new SetShadowValueCommand( editor, object, 'bias', objectShadowBias.getValue() ) );
|
|
604
|
+
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
if ( object.shadow.normalBias !== objectShadowNormalBias.getValue() ) {
|
|
608
|
+
|
|
609
|
+
editor.execute( new SetShadowValueCommand( editor, object, 'normalBias', objectShadowNormalBias.getValue() ) );
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
if ( object.shadow.radius !== objectShadowRadius.getValue() ) {
|
|
614
|
+
|
|
615
|
+
editor.execute( new SetShadowValueCommand( editor, object, 'radius', objectShadowRadius.getValue() ) );
|
|
616
|
+
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
try {
|
|
622
|
+
|
|
623
|
+
const userData = JSON.parse( objectUserData.getValue() );
|
|
624
|
+
if ( JSON.stringify( object.userData ) != JSON.stringify( userData ) ) {
|
|
625
|
+
|
|
626
|
+
editor.execute( new SetValueCommand( editor, object, 'userData', userData ) );
|
|
627
|
+
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
} catch ( exception ) {
|
|
631
|
+
|
|
632
|
+
console.warn( exception );
|
|
633
|
+
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function updateRows( object ) {
|
|
641
|
+
|
|
642
|
+
const properties = {
|
|
643
|
+
'fov': objectFovRow,
|
|
644
|
+
'left': objectLeftRow,
|
|
645
|
+
'right': objectRightRow,
|
|
646
|
+
'top': objectTopRow,
|
|
647
|
+
'bottom': objectBottomRow,
|
|
648
|
+
'near': objectNearRow,
|
|
649
|
+
'far': objectFarRow,
|
|
650
|
+
'intensity': objectIntensityRow,
|
|
651
|
+
'color': objectColorRow,
|
|
652
|
+
'groundColor': objectGroundColorRow,
|
|
653
|
+
'distance': objectDistanceRow,
|
|
654
|
+
'angle': objectAngleRow,
|
|
655
|
+
'penumbra': objectPenumbraRow,
|
|
656
|
+
'decay': objectDecayRow,
|
|
657
|
+
'castShadow': objectShadowRow,
|
|
658
|
+
'receiveShadow': objectReceiveShadow,
|
|
659
|
+
'shadow': [ objectShadowIntensityRow, objectShadowBiasRow, objectShadowNormalBiasRow, objectShadowRadiusRow ]
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
for ( const property in properties ) {
|
|
663
|
+
|
|
664
|
+
const uiElement = properties[ property ];
|
|
665
|
+
|
|
666
|
+
if ( Array.isArray( uiElement ) === true ) {
|
|
667
|
+
|
|
668
|
+
for ( let i = 0; i < uiElement.length; i ++ ) {
|
|
669
|
+
|
|
670
|
+
uiElement[ i ].setDisplay( object[ property ] !== undefined ? '' : 'none' );
|
|
671
|
+
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
} else {
|
|
675
|
+
|
|
676
|
+
uiElement.setDisplay( object[ property ] !== undefined ? '' : 'none' );
|
|
677
|
+
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
//
|
|
683
|
+
|
|
684
|
+
if ( object.isLight ) {
|
|
685
|
+
|
|
686
|
+
objectReceiveShadow.setDisplay( 'none' );
|
|
687
|
+
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if ( object.isAmbientLight || object.isHemisphereLight ) {
|
|
691
|
+
|
|
692
|
+
objectShadowRow.setDisplay( 'none' );
|
|
693
|
+
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
function updateTransformRows( object ) {
|
|
699
|
+
|
|
700
|
+
if ( object.isLight ) {
|
|
701
|
+
|
|
702
|
+
objectRotationRow.setDisplay( 'none' );
|
|
703
|
+
objectScaleRow.setDisplay( 'none' );
|
|
704
|
+
|
|
705
|
+
} else {
|
|
706
|
+
|
|
707
|
+
objectRotationRow.setDisplay( '' );
|
|
708
|
+
objectScaleRow.setDisplay( '' );
|
|
709
|
+
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// events
|
|
715
|
+
|
|
716
|
+
signals.objectSelected.add( function ( object ) {
|
|
717
|
+
|
|
718
|
+
if ( object !== null ) {
|
|
719
|
+
|
|
720
|
+
container.setDisplay( 'block' );
|
|
721
|
+
|
|
722
|
+
updateRows( object );
|
|
723
|
+
updateUI( object );
|
|
724
|
+
|
|
725
|
+
} else {
|
|
726
|
+
|
|
727
|
+
container.setDisplay( 'none' );
|
|
728
|
+
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
} );
|
|
732
|
+
|
|
733
|
+
signals.objectChanged.add( function ( object ) {
|
|
734
|
+
|
|
735
|
+
if ( object !== editor.selected ) return;
|
|
736
|
+
|
|
737
|
+
updateUI( object );
|
|
738
|
+
|
|
739
|
+
} );
|
|
740
|
+
|
|
741
|
+
signals.refreshSidebarObject3D.add( function ( object ) {
|
|
742
|
+
|
|
743
|
+
if ( object !== editor.selected ) return;
|
|
744
|
+
|
|
745
|
+
updateUI( object );
|
|
746
|
+
|
|
747
|
+
} );
|
|
748
|
+
|
|
749
|
+
function updateUI( object ) {
|
|
750
|
+
|
|
751
|
+
objectType.setValue( object.type );
|
|
752
|
+
|
|
753
|
+
objectUUID.setValue( object.uuid );
|
|
754
|
+
objectName.setValue( object.name );
|
|
755
|
+
|
|
756
|
+
objectPositionX.setValue( object.position.x );
|
|
757
|
+
objectPositionY.setValue( object.position.y );
|
|
758
|
+
objectPositionZ.setValue( object.position.z );
|
|
759
|
+
|
|
760
|
+
objectRotationX.setValue( object.rotation.x * THREE.MathUtils.RAD2DEG );
|
|
761
|
+
objectRotationY.setValue( object.rotation.y * THREE.MathUtils.RAD2DEG );
|
|
762
|
+
objectRotationZ.setValue( object.rotation.z * THREE.MathUtils.RAD2DEG );
|
|
763
|
+
|
|
764
|
+
objectScaleX.setValue( object.scale.x );
|
|
765
|
+
objectScaleY.setValue( object.scale.y );
|
|
766
|
+
objectScaleZ.setValue( object.scale.z );
|
|
767
|
+
|
|
768
|
+
if ( object.fov !== undefined ) {
|
|
769
|
+
|
|
770
|
+
objectFov.setValue( object.fov );
|
|
771
|
+
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
if ( object.left !== undefined ) {
|
|
775
|
+
|
|
776
|
+
objectLeft.setValue( object.left );
|
|
777
|
+
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if ( object.right !== undefined ) {
|
|
781
|
+
|
|
782
|
+
objectRight.setValue( object.right );
|
|
783
|
+
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
if ( object.top !== undefined ) {
|
|
787
|
+
|
|
788
|
+
objectTop.setValue( object.top );
|
|
789
|
+
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if ( object.bottom !== undefined ) {
|
|
793
|
+
|
|
794
|
+
objectBottom.setValue( object.bottom );
|
|
795
|
+
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
if ( object.near !== undefined ) {
|
|
799
|
+
|
|
800
|
+
objectNear.setValue( object.near );
|
|
801
|
+
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if ( object.far !== undefined ) {
|
|
805
|
+
|
|
806
|
+
objectFar.setValue( object.far );
|
|
807
|
+
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if ( object.intensity !== undefined ) {
|
|
811
|
+
|
|
812
|
+
objectIntensity.setValue( object.intensity );
|
|
813
|
+
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
if ( object.color !== undefined ) {
|
|
817
|
+
|
|
818
|
+
objectColor.setHexValue( object.color.getHexString() );
|
|
819
|
+
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if ( object.groundColor !== undefined ) {
|
|
823
|
+
|
|
824
|
+
objectGroundColor.setHexValue( object.groundColor.getHexString() );
|
|
825
|
+
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
if ( object.distance !== undefined ) {
|
|
829
|
+
|
|
830
|
+
objectDistance.setValue( object.distance );
|
|
831
|
+
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
if ( object.angle !== undefined ) {
|
|
835
|
+
|
|
836
|
+
objectAngle.setValue( object.angle );
|
|
837
|
+
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
if ( object.penumbra !== undefined ) {
|
|
841
|
+
|
|
842
|
+
objectPenumbra.setValue( object.penumbra );
|
|
843
|
+
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
if ( object.decay !== undefined ) {
|
|
847
|
+
|
|
848
|
+
objectDecay.setValue( object.decay );
|
|
849
|
+
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
if ( object.castShadow !== undefined ) {
|
|
853
|
+
|
|
854
|
+
objectCastShadow.setValue( object.castShadow );
|
|
855
|
+
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if ( object.receiveShadow !== undefined ) {
|
|
859
|
+
|
|
860
|
+
objectReceiveShadow.setValue( object.receiveShadow );
|
|
861
|
+
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if ( object.shadow !== undefined ) {
|
|
865
|
+
|
|
866
|
+
objectShadowIntensity.setValue( object.shadow.intensity );
|
|
867
|
+
objectShadowBias.setValue( object.shadow.bias );
|
|
868
|
+
objectShadowNormalBias.setValue( object.shadow.normalBias );
|
|
869
|
+
objectShadowRadius.setValue( object.shadow.radius );
|
|
870
|
+
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
objectVisible.setValue( object.visible );
|
|
874
|
+
objectFrustumCulled.setValue( object.frustumCulled );
|
|
875
|
+
objectRenderOrder.setValue( object.renderOrder );
|
|
876
|
+
|
|
877
|
+
try {
|
|
878
|
+
|
|
879
|
+
objectUserData.setValue( JSON.stringify( object.userData, null, ' ' ) );
|
|
880
|
+
|
|
881
|
+
} catch ( error ) {
|
|
882
|
+
|
|
883
|
+
console.log( error );
|
|
884
|
+
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
objectUserData.setBorderColor( 'transparent' );
|
|
888
|
+
objectUserData.setBackgroundColor( '' );
|
|
889
|
+
|
|
890
|
+
updateTransformRows( object );
|
|
891
|
+
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
return container;
|
|
895
|
+
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
export { SidebarObject };
|