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,332 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
|
|
3
|
+
import { UIPanel, UIRow, UIText, UIInput, UIButton, UISpan, UITextArea } from './libs/ui.js';
|
|
4
|
+
|
|
5
|
+
import { SetGeometryValueCommand } from './commands/SetGeometryValueCommand.js';
|
|
6
|
+
|
|
7
|
+
import { SidebarGeometryBufferGeometry } from './Sidebar.Geometry.BufferGeometry.js';
|
|
8
|
+
import { SidebarGeometryModifiers } from './Sidebar.Geometry.Modifiers.js';
|
|
9
|
+
|
|
10
|
+
import { VertexNormalsHelper } from 'three/addons/helpers/VertexNormalsHelper.js';
|
|
11
|
+
|
|
12
|
+
function SidebarGeometry( editor ) {
|
|
13
|
+
|
|
14
|
+
const strings = editor.strings;
|
|
15
|
+
|
|
16
|
+
const signals = editor.signals;
|
|
17
|
+
|
|
18
|
+
const container = new UIPanel();
|
|
19
|
+
container.setBorderTop( '0' );
|
|
20
|
+
container.setDisplay( 'none' );
|
|
21
|
+
container.setPaddingTop( '20px' );
|
|
22
|
+
|
|
23
|
+
let currentGeometryType = null;
|
|
24
|
+
|
|
25
|
+
// Actions
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
let objectActions = new UISelect().setPosition( 'absolute' ).setRight( '8px' ).setFontSize( '11px' );
|
|
29
|
+
objectActions.setOptions( {
|
|
30
|
+
|
|
31
|
+
'Actions': 'Actions',
|
|
32
|
+
'Center': 'Center',
|
|
33
|
+
'Convert': 'Convert',
|
|
34
|
+
'Flatten': 'Flatten'
|
|
35
|
+
|
|
36
|
+
} );
|
|
37
|
+
objectActions.onClick( function ( event ) {
|
|
38
|
+
|
|
39
|
+
event.stopPropagation(); // Avoid panel collapsing
|
|
40
|
+
|
|
41
|
+
} );
|
|
42
|
+
objectActions.onChange( function ( event ) {
|
|
43
|
+
|
|
44
|
+
let action = this.getValue();
|
|
45
|
+
|
|
46
|
+
let object = editor.selected;
|
|
47
|
+
let geometry = object.geometry;
|
|
48
|
+
|
|
49
|
+
if ( confirm( action + ' ' + object.name + '?' ) === false ) return;
|
|
50
|
+
|
|
51
|
+
switch ( action ) {
|
|
52
|
+
|
|
53
|
+
case 'Center':
|
|
54
|
+
|
|
55
|
+
let offset = geometry.center();
|
|
56
|
+
|
|
57
|
+
let newPosition = object.position.clone();
|
|
58
|
+
newPosition.sub( offset );
|
|
59
|
+
editor.execute( new SetPositionCommand( editor, object, newPosition ) );
|
|
60
|
+
|
|
61
|
+
editor.signals.geometryChanged.dispatch( object );
|
|
62
|
+
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case 'Flatten':
|
|
66
|
+
|
|
67
|
+
let newGeometry = geometry.clone();
|
|
68
|
+
newGeometry.uuid = geometry.uuid;
|
|
69
|
+
newGeometry.applyMatrix( object.matrix );
|
|
70
|
+
|
|
71
|
+
let cmds = [ new SetGeometryCommand( editor, object, newGeometry ),
|
|
72
|
+
new SetPositionCommand( editor, object, new THREE.Vector3( 0, 0, 0 ) ),
|
|
73
|
+
new SetRotationCommand( editor, object, new THREE.Euler( 0, 0, 0 ) ),
|
|
74
|
+
new SetScaleCommand( editor, object, new THREE.Vector3( 1, 1, 1 ) ) ];
|
|
75
|
+
|
|
76
|
+
editor.execute( new MultiCmdsCommand( editor, cmds ), 'Flatten Geometry' );
|
|
77
|
+
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.setValue( 'Actions' );
|
|
83
|
+
|
|
84
|
+
} );
|
|
85
|
+
container.addStatic( objectActions );
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
// type
|
|
89
|
+
|
|
90
|
+
const geometryTypeRow = new UIRow();
|
|
91
|
+
const geometryType = new UIText();
|
|
92
|
+
|
|
93
|
+
geometryTypeRow.add( new UIText( strings.getKey( 'sidebar/geometry/type' ) ).setClass( 'Label' ) );
|
|
94
|
+
geometryTypeRow.add( geometryType );
|
|
95
|
+
|
|
96
|
+
container.add( geometryTypeRow );
|
|
97
|
+
|
|
98
|
+
// uuid
|
|
99
|
+
|
|
100
|
+
const geometryUUIDRow = new UIRow();
|
|
101
|
+
const geometryUUID = new UIInput().setWidth( '102px' ).setFontSize( '12px' ).setDisabled( true );
|
|
102
|
+
const geometryUUIDRenew = new UIButton( strings.getKey( 'sidebar/geometry/new' ) ).setMarginLeft( '7px' ).onClick( function () {
|
|
103
|
+
|
|
104
|
+
geometryUUID.setValue( THREE.MathUtils.generateUUID() );
|
|
105
|
+
|
|
106
|
+
editor.execute( new SetGeometryValueCommand( editor, editor.selected, 'uuid', geometryUUID.getValue() ) );
|
|
107
|
+
|
|
108
|
+
} );
|
|
109
|
+
|
|
110
|
+
geometryUUIDRow.add( new UIText( strings.getKey( 'sidebar/geometry/uuid' ) ).setClass( 'Label' ) );
|
|
111
|
+
geometryUUIDRow.add( geometryUUID );
|
|
112
|
+
geometryUUIDRow.add( geometryUUIDRenew );
|
|
113
|
+
|
|
114
|
+
container.add( geometryUUIDRow );
|
|
115
|
+
|
|
116
|
+
// name
|
|
117
|
+
|
|
118
|
+
const geometryNameRow = new UIRow();
|
|
119
|
+
const geometryName = new UIInput().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
|
|
120
|
+
|
|
121
|
+
editor.execute( new SetGeometryValueCommand( editor, editor.selected, 'name', geometryName.getValue() ) );
|
|
122
|
+
|
|
123
|
+
} );
|
|
124
|
+
|
|
125
|
+
geometryNameRow.add( new UIText( strings.getKey( 'sidebar/geometry/name' ) ).setClass( 'Label' ) );
|
|
126
|
+
geometryNameRow.add( geometryName );
|
|
127
|
+
|
|
128
|
+
container.add( geometryNameRow );
|
|
129
|
+
|
|
130
|
+
// parameters
|
|
131
|
+
|
|
132
|
+
const parameters = new UISpan();
|
|
133
|
+
container.add( parameters );
|
|
134
|
+
|
|
135
|
+
// buffergeometry
|
|
136
|
+
|
|
137
|
+
container.add( new SidebarGeometryBufferGeometry( editor ) );
|
|
138
|
+
|
|
139
|
+
// Size
|
|
140
|
+
|
|
141
|
+
const geometryBoundingBox = new UIText().setFontSize( '12px' );
|
|
142
|
+
|
|
143
|
+
const geometryBoundingBoxRow = new UIRow();
|
|
144
|
+
geometryBoundingBoxRow.add( new UIText( strings.getKey( 'sidebar/geometry/bounds' ) ).setClass( 'Label' ) );
|
|
145
|
+
geometryBoundingBoxRow.add( geometryBoundingBox );
|
|
146
|
+
container.add( geometryBoundingBoxRow );
|
|
147
|
+
|
|
148
|
+
// userData
|
|
149
|
+
|
|
150
|
+
const geometryUserDataRow = new UIRow();
|
|
151
|
+
const geometryUserData = new UITextArea().setValue( '{}' ).setWidth( '150px' ).setHeight( '40px' ).setFontSize( '12px' ).onChange( function () {
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
|
|
155
|
+
const userData = JSON.parse( geometryUserData.getValue() );
|
|
156
|
+
|
|
157
|
+
if ( JSON.stringify( editor.selected.geometry.userData ) != JSON.stringify( userData ) ) {
|
|
158
|
+
|
|
159
|
+
editor.execute( new SetGeometryValueCommand( editor, editor.selected, 'userData', userData ) );
|
|
160
|
+
|
|
161
|
+
build();
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
} catch ( exception ) {
|
|
166
|
+
|
|
167
|
+
console.warn( exception );
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
} );
|
|
172
|
+
geometryUserData.onKeyUp( function () {
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
|
|
176
|
+
JSON.parse( geometryUserData.getValue() );
|
|
177
|
+
|
|
178
|
+
geometryUserData.dom.classList.add( 'success' );
|
|
179
|
+
geometryUserData.dom.classList.remove( 'fail' );
|
|
180
|
+
|
|
181
|
+
} catch ( error ) {
|
|
182
|
+
|
|
183
|
+
geometryUserData.dom.classList.remove( 'success' );
|
|
184
|
+
geometryUserData.dom.classList.add( 'fail' );
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
} );
|
|
189
|
+
|
|
190
|
+
geometryUserDataRow.add( new UIText( strings.getKey( 'sidebar/geometry/userdata' ) ).setClass( 'Label' ) );
|
|
191
|
+
geometryUserDataRow.add( geometryUserData );
|
|
192
|
+
|
|
193
|
+
container.add( geometryUserDataRow );
|
|
194
|
+
|
|
195
|
+
// Helpers
|
|
196
|
+
|
|
197
|
+
const helpersRow = new UIRow().setMarginLeft( '120px' );
|
|
198
|
+
container.add( helpersRow );
|
|
199
|
+
|
|
200
|
+
const vertexNormalsButton = new UIButton( strings.getKey( 'sidebar/geometry/show_vertex_normals' ) );
|
|
201
|
+
vertexNormalsButton.onClick( function () {
|
|
202
|
+
|
|
203
|
+
const object = editor.selected;
|
|
204
|
+
|
|
205
|
+
if ( editor.helpers[ object.id ] === undefined ) {
|
|
206
|
+
|
|
207
|
+
editor.addHelper( object, new VertexNormalsHelper( object ) );
|
|
208
|
+
|
|
209
|
+
} else {
|
|
210
|
+
|
|
211
|
+
editor.removeHelper( object );
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
signals.sceneGraphChanged.dispatch();
|
|
216
|
+
|
|
217
|
+
} );
|
|
218
|
+
helpersRow.add( vertexNormalsButton );
|
|
219
|
+
|
|
220
|
+
// Export JSON
|
|
221
|
+
|
|
222
|
+
const exportJson = new UIButton( strings.getKey( 'sidebar/geometry/export' ) );
|
|
223
|
+
exportJson.setMarginLeft( '120px' );
|
|
224
|
+
exportJson.onClick( function () {
|
|
225
|
+
|
|
226
|
+
const object = editor.selected;
|
|
227
|
+
const geometry = object.geometry;
|
|
228
|
+
|
|
229
|
+
let output = geometry.toJSON();
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
|
|
233
|
+
output = JSON.stringify( output, null, '\t' );
|
|
234
|
+
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
|
|
235
|
+
|
|
236
|
+
} catch ( e ) {
|
|
237
|
+
|
|
238
|
+
output = JSON.stringify( output );
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
editor.utils.save( new Blob( [ output ] ), `${ geometryName.getValue() || 'geometry' }.json` );
|
|
243
|
+
|
|
244
|
+
} );
|
|
245
|
+
container.add( exportJson );
|
|
246
|
+
|
|
247
|
+
//
|
|
248
|
+
|
|
249
|
+
async function build() {
|
|
250
|
+
|
|
251
|
+
const object = editor.selected;
|
|
252
|
+
|
|
253
|
+
if ( object && object.geometry ) {
|
|
254
|
+
|
|
255
|
+
const geometry = object.geometry;
|
|
256
|
+
|
|
257
|
+
container.setDisplay( 'block' );
|
|
258
|
+
|
|
259
|
+
geometryType.setValue( geometry.type );
|
|
260
|
+
|
|
261
|
+
geometryUUID.setValue( geometry.uuid );
|
|
262
|
+
geometryName.setValue( geometry.name );
|
|
263
|
+
|
|
264
|
+
//
|
|
265
|
+
|
|
266
|
+
if ( currentGeometryType !== geometry.type ) {
|
|
267
|
+
|
|
268
|
+
parameters.clear();
|
|
269
|
+
|
|
270
|
+
if ( geometry.type === 'BufferGeometry' ) {
|
|
271
|
+
|
|
272
|
+
parameters.add( new SidebarGeometryModifiers( editor, object ) );
|
|
273
|
+
|
|
274
|
+
} else {
|
|
275
|
+
|
|
276
|
+
const { GeometryParametersPanel } = await import( `./Sidebar.Geometry.${ geometry.type }.js` );
|
|
277
|
+
|
|
278
|
+
parameters.add( new GeometryParametersPanel( editor, object ) );
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
currentGeometryType = geometry.type;
|
|
283
|
+
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if ( geometry.boundingBox === null ) geometry.computeBoundingBox();
|
|
287
|
+
|
|
288
|
+
const boundingBox = geometry.boundingBox;
|
|
289
|
+
const x = Math.floor( ( boundingBox.max.x - boundingBox.min.x ) * 1000 ) / 1000;
|
|
290
|
+
const y = Math.floor( ( boundingBox.max.y - boundingBox.min.y ) * 1000 ) / 1000;
|
|
291
|
+
const z = Math.floor( ( boundingBox.max.z - boundingBox.min.z ) * 1000 ) / 1000;
|
|
292
|
+
|
|
293
|
+
geometryBoundingBox.setInnerHTML( `${x}<br/>${y}<br/>${z}` );
|
|
294
|
+
|
|
295
|
+
helpersRow.setDisplay( geometry.hasAttribute( 'normal' ) ? '' : 'none' );
|
|
296
|
+
|
|
297
|
+
geometryUserData.setValue( JSON.stringify( geometry.userData, null, ' ' ) );
|
|
298
|
+
|
|
299
|
+
//
|
|
300
|
+
|
|
301
|
+
const helper = editor.helpers[ object.id ];
|
|
302
|
+
|
|
303
|
+
if ( helper !== undefined ) {
|
|
304
|
+
|
|
305
|
+
editor.removeHelper( object );
|
|
306
|
+
editor.addHelper( object, new VertexNormalsHelper( object ) );
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
} else {
|
|
311
|
+
|
|
312
|
+
container.setDisplay( 'none' );
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
signals.objectSelected.add( function () {
|
|
319
|
+
|
|
320
|
+
currentGeometryType = null;
|
|
321
|
+
|
|
322
|
+
build();
|
|
323
|
+
|
|
324
|
+
} );
|
|
325
|
+
|
|
326
|
+
signals.geometryChanged.add( build );
|
|
327
|
+
|
|
328
|
+
return container;
|
|
329
|
+
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export { SidebarGeometry };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { UICheckbox, UIRow, UIText } from './libs/ui.js';
|
|
2
|
+
import { SetMaterialValueCommand } from './commands/SetMaterialValueCommand.js';
|
|
3
|
+
|
|
4
|
+
function SidebarMaterialBooleanProperty( editor, property, name ) {
|
|
5
|
+
|
|
6
|
+
const signals = editor.signals;
|
|
7
|
+
|
|
8
|
+
const container = new UIRow();
|
|
9
|
+
container.add( new UIText( name ).setClass( 'Label' ) );
|
|
10
|
+
|
|
11
|
+
const boolean = new UICheckbox().setLeft( '100px' ).onChange( onChange );
|
|
12
|
+
container.add( boolean );
|
|
13
|
+
|
|
14
|
+
let object = null;
|
|
15
|
+
let materialSlot = null;
|
|
16
|
+
let material = null;
|
|
17
|
+
|
|
18
|
+
function onChange() {
|
|
19
|
+
|
|
20
|
+
if ( material[ property ] !== boolean.getValue() ) {
|
|
21
|
+
|
|
22
|
+
editor.execute( new SetMaterialValueCommand( editor, object, property, boolean.getValue(), materialSlot ) );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function update( currentObject, currentMaterialSlot = 0 ) {
|
|
29
|
+
|
|
30
|
+
object = currentObject;
|
|
31
|
+
materialSlot = currentMaterialSlot;
|
|
32
|
+
|
|
33
|
+
if ( object === null ) return;
|
|
34
|
+
if ( object.material === undefined ) return;
|
|
35
|
+
|
|
36
|
+
material = editor.getObjectMaterial( object, materialSlot );
|
|
37
|
+
|
|
38
|
+
if ( property in material ) {
|
|
39
|
+
|
|
40
|
+
boolean.setValue( material[ property ] );
|
|
41
|
+
container.setDisplay( '' );
|
|
42
|
+
|
|
43
|
+
} else {
|
|
44
|
+
|
|
45
|
+
container.setDisplay( 'none' );
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
signals.objectSelected.add( update );
|
|
54
|
+
signals.materialChanged.add( update );
|
|
55
|
+
|
|
56
|
+
return container;
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { SidebarMaterialBooleanProperty };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { UIColor, UINumber, UIRow, UIText } from './libs/ui.js';
|
|
2
|
+
import { SetMaterialColorCommand } from './commands/SetMaterialColorCommand.js';
|
|
3
|
+
import { SetMaterialValueCommand } from './commands/SetMaterialValueCommand.js';
|
|
4
|
+
|
|
5
|
+
function SidebarMaterialColorProperty( editor, property, name ) {
|
|
6
|
+
|
|
7
|
+
const signals = editor.signals;
|
|
8
|
+
|
|
9
|
+
const container = new UIRow();
|
|
10
|
+
container.add( new UIText( name ).setClass( 'Label' ) );
|
|
11
|
+
|
|
12
|
+
const color = new UIColor().onInput( onChange );
|
|
13
|
+
container.add( color );
|
|
14
|
+
|
|
15
|
+
let intensity;
|
|
16
|
+
|
|
17
|
+
if ( property === 'emissive' ) {
|
|
18
|
+
|
|
19
|
+
intensity = new UINumber( 1 ).setWidth( '30px' ).setRange( 0, Infinity ).onChange( onChange );
|
|
20
|
+
container.add( intensity );
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let object = null;
|
|
25
|
+
let materialSlot = null;
|
|
26
|
+
let material = null;
|
|
27
|
+
|
|
28
|
+
function onChange() {
|
|
29
|
+
|
|
30
|
+
if ( material[ property ].getHex() !== color.getHexValue() ) {
|
|
31
|
+
|
|
32
|
+
editor.execute( new SetMaterialColorCommand( editor, object, property, color.getHexValue(), materialSlot ) );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ( intensity !== undefined ) {
|
|
37
|
+
|
|
38
|
+
if ( material[ `${ property }Intensity` ] !== intensity.getValue() ) {
|
|
39
|
+
|
|
40
|
+
editor.execute( new SetMaterialValueCommand( editor, object, `${ property }Intensity`, intensity.getValue(), materialSlot ) );
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function update( currentObject, currentMaterialSlot = 0 ) {
|
|
49
|
+
|
|
50
|
+
object = currentObject;
|
|
51
|
+
materialSlot = currentMaterialSlot;
|
|
52
|
+
|
|
53
|
+
if ( object === null ) return;
|
|
54
|
+
if ( object.material === undefined ) return;
|
|
55
|
+
|
|
56
|
+
material = editor.getObjectMaterial( object, materialSlot );
|
|
57
|
+
|
|
58
|
+
if ( property in material ) {
|
|
59
|
+
|
|
60
|
+
color.setHexValue( material[ property ].getHexString() );
|
|
61
|
+
|
|
62
|
+
if ( intensity !== undefined ) {
|
|
63
|
+
|
|
64
|
+
intensity.setValue( material[ `${ property }Intensity` ] );
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
container.setDisplay( '' );
|
|
69
|
+
|
|
70
|
+
} else {
|
|
71
|
+
|
|
72
|
+
container.setDisplay( 'none' );
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//
|
|
79
|
+
|
|
80
|
+
signals.objectSelected.add( update );
|
|
81
|
+
signals.materialChanged.add( update );
|
|
82
|
+
|
|
83
|
+
return container;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { SidebarMaterialColorProperty };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { UIRow, UISelect, UIText } from './libs/ui.js';
|
|
2
|
+
import { SetMaterialValueCommand } from './commands/SetMaterialValueCommand.js';
|
|
3
|
+
|
|
4
|
+
function SidebarMaterialConstantProperty( editor, property, name, options ) {
|
|
5
|
+
|
|
6
|
+
const signals = editor.signals;
|
|
7
|
+
|
|
8
|
+
const container = new UIRow();
|
|
9
|
+
container.add( new UIText( name ).setClass( 'Label' ) );
|
|
10
|
+
|
|
11
|
+
const constant = new UISelect().setOptions( options ).onChange( onChange );
|
|
12
|
+
container.add( constant );
|
|
13
|
+
|
|
14
|
+
let object = null;
|
|
15
|
+
let materialSlot = null;
|
|
16
|
+
let material = null;
|
|
17
|
+
|
|
18
|
+
function onChange() {
|
|
19
|
+
|
|
20
|
+
const value = parseInt( constant.getValue() );
|
|
21
|
+
|
|
22
|
+
if ( material[ property ] !== value ) {
|
|
23
|
+
|
|
24
|
+
editor.execute( new SetMaterialValueCommand( editor, object, property, value, materialSlot ) );
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function update( currentObject, currentMaterialSlot = 0 ) {
|
|
31
|
+
|
|
32
|
+
object = currentObject;
|
|
33
|
+
materialSlot = currentMaterialSlot;
|
|
34
|
+
|
|
35
|
+
if ( object === null ) return;
|
|
36
|
+
if ( object.material === undefined ) return;
|
|
37
|
+
|
|
38
|
+
material = editor.getObjectMaterial( object, materialSlot );
|
|
39
|
+
|
|
40
|
+
if ( property in material ) {
|
|
41
|
+
|
|
42
|
+
constant.setValue( material[ property ] );
|
|
43
|
+
container.setDisplay( '' );
|
|
44
|
+
|
|
45
|
+
} else {
|
|
46
|
+
|
|
47
|
+
container.setDisplay( 'none' );
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//
|
|
54
|
+
|
|
55
|
+
signals.objectSelected.add( update );
|
|
56
|
+
signals.materialChanged.add( update );
|
|
57
|
+
|
|
58
|
+
return container;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { SidebarMaterialConstantProperty };
|