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,249 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
|
|
3
|
+
import { UICheckbox, UIDiv, UINumber, UIRow, UIText } from './libs/ui.js';
|
|
4
|
+
import { UITexture } from './libs/ui.three.js';
|
|
5
|
+
import { SetMaterialMapCommand } from './commands/SetMaterialMapCommand.js';
|
|
6
|
+
import { SetMaterialValueCommand } from './commands/SetMaterialValueCommand.js';
|
|
7
|
+
import { SetMaterialRangeCommand } from './commands/SetMaterialRangeCommand.js';
|
|
8
|
+
import { SetMaterialVectorCommand } from './commands/SetMaterialVectorCommand.js';
|
|
9
|
+
|
|
10
|
+
function SidebarMaterialMapProperty( editor, property, name ) {
|
|
11
|
+
|
|
12
|
+
const signals = editor.signals;
|
|
13
|
+
|
|
14
|
+
const container = new UIRow();
|
|
15
|
+
container.add( new UIText( name ).setClass( 'Label' ) );
|
|
16
|
+
|
|
17
|
+
const enabled = new UICheckbox( false ).setMarginRight( '8px' ).onChange( onChange );
|
|
18
|
+
container.add( enabled );
|
|
19
|
+
|
|
20
|
+
const map = new UITexture( editor ).onChange( onMapChange );
|
|
21
|
+
container.add( map );
|
|
22
|
+
|
|
23
|
+
const mapType = property.replace( 'Map', '' );
|
|
24
|
+
|
|
25
|
+
const colorMaps = [ 'map', 'emissiveMap', 'sheenColorMap', 'specularColorMap', 'envMap' ];
|
|
26
|
+
|
|
27
|
+
let intensity;
|
|
28
|
+
|
|
29
|
+
if ( property === 'aoMap' ) {
|
|
30
|
+
|
|
31
|
+
intensity = new UINumber( 1 ).setWidth( '30px' ).setRange( 0, 1 ).onChange( onIntensityChange );
|
|
32
|
+
container.add( intensity );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let scale;
|
|
37
|
+
|
|
38
|
+
if ( property === 'bumpMap' || property === 'displacementMap' ) {
|
|
39
|
+
|
|
40
|
+
scale = new UINumber().setWidth( '30px' ).onChange( onScaleChange );
|
|
41
|
+
container.add( scale );
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let scaleX, scaleY;
|
|
46
|
+
|
|
47
|
+
if ( property === 'normalMap' || property === 'clearcoatNormalMap' ) {
|
|
48
|
+
|
|
49
|
+
scaleX = new UINumber().setWidth( '30px' ).onChange( onScaleXYChange );
|
|
50
|
+
container.add( scaleX );
|
|
51
|
+
|
|
52
|
+
scaleY = new UINumber().setWidth( '30px' ).onChange( onScaleXYChange );
|
|
53
|
+
container.add( scaleY );
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let rangeMin, rangeMax;
|
|
58
|
+
|
|
59
|
+
if ( property === 'iridescenceThicknessMap' ) {
|
|
60
|
+
|
|
61
|
+
const range = new UIDiv().setMarginLeft( '3px' );
|
|
62
|
+
container.add( range );
|
|
63
|
+
|
|
64
|
+
const rangeMinRow = new UIRow().setMarginBottom( '0px' ).setStyle( 'min-height', '0px' );
|
|
65
|
+
range.add( rangeMinRow );
|
|
66
|
+
|
|
67
|
+
rangeMinRow.add( new UIText( 'min:' ).setWidth( '35px' ) );
|
|
68
|
+
|
|
69
|
+
rangeMin = new UINumber().setWidth( '40px' ).onChange( onRangeChange );
|
|
70
|
+
rangeMinRow.add( rangeMin );
|
|
71
|
+
|
|
72
|
+
const rangeMaxRow = new UIRow().setMarginBottom( '6px' ).setStyle( 'min-height', '0px' );
|
|
73
|
+
range.add( rangeMaxRow );
|
|
74
|
+
|
|
75
|
+
rangeMaxRow.add( new UIText( 'max:' ).setWidth( '35px' ) );
|
|
76
|
+
|
|
77
|
+
rangeMax = new UINumber().setWidth( '40px' ).onChange( onRangeChange );
|
|
78
|
+
rangeMaxRow.add( rangeMax );
|
|
79
|
+
|
|
80
|
+
// Additional settings for iridescenceThicknessMap
|
|
81
|
+
// Please add conditional if more maps are having a range property
|
|
82
|
+
rangeMin.setPrecision( 0 ).setRange( 0, Infinity ).setNudge( 1 ).setStep( 10 ).setUnit( 'nm' );
|
|
83
|
+
rangeMax.setPrecision( 0 ).setRange( 0, Infinity ).setNudge( 1 ).setStep( 10 ).setUnit( 'nm' );
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let object = null;
|
|
88
|
+
let materialSlot = null;
|
|
89
|
+
let material = null;
|
|
90
|
+
|
|
91
|
+
function onChange() {
|
|
92
|
+
|
|
93
|
+
const newMap = enabled.getValue() ? map.getValue() : null;
|
|
94
|
+
|
|
95
|
+
if ( material[ property ] !== newMap ) {
|
|
96
|
+
|
|
97
|
+
if ( newMap !== null ) {
|
|
98
|
+
|
|
99
|
+
const geometry = object.geometry;
|
|
100
|
+
|
|
101
|
+
if ( geometry.hasAttribute( 'uv' ) === false ) console.warn( 'Geometry doesn\'t have uvs:', geometry );
|
|
102
|
+
|
|
103
|
+
if ( property === 'envMap' ) newMap.mapping = THREE.EquirectangularReflectionMapping;
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
editor.execute( new SetMaterialMapCommand( editor, object, property, newMap, materialSlot ) );
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function onMapChange( texture ) {
|
|
114
|
+
|
|
115
|
+
if ( texture !== null ) {
|
|
116
|
+
|
|
117
|
+
if ( colorMaps.includes( property ) && texture.isDataTexture !== true && texture.colorSpace !== THREE.SRGBColorSpace ) {
|
|
118
|
+
|
|
119
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
120
|
+
material.needsUpdate = true;
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
enabled.setDisabled( false );
|
|
127
|
+
|
|
128
|
+
onChange();
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function onIntensityChange() {
|
|
133
|
+
|
|
134
|
+
if ( material[ `${ property }Intensity` ] !== intensity.getValue() ) {
|
|
135
|
+
|
|
136
|
+
editor.execute( new SetMaterialValueCommand( editor, object, `${ property }Intensity`, intensity.getValue(), materialSlot ) );
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function onScaleChange() {
|
|
143
|
+
|
|
144
|
+
if ( material[ `${ mapType }Scale` ] !== scale.getValue() ) {
|
|
145
|
+
|
|
146
|
+
editor.execute( new SetMaterialValueCommand( editor, object, `${ mapType }Scale`, scale.getValue(), materialSlot ) );
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function onScaleXYChange() {
|
|
153
|
+
|
|
154
|
+
const value = [ scaleX.getValue(), scaleY.getValue() ];
|
|
155
|
+
|
|
156
|
+
if ( material[ `${ mapType }Scale` ].x !== value[ 0 ] || material[ `${ mapType }Scale` ].y !== value[ 1 ] ) {
|
|
157
|
+
|
|
158
|
+
editor.execute( new SetMaterialVectorCommand( editor, object, `${ mapType }Scale`, value, materialSlot ) );
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function onRangeChange() {
|
|
165
|
+
|
|
166
|
+
const value = [ rangeMin.getValue(), rangeMax.getValue() ];
|
|
167
|
+
|
|
168
|
+
if ( material[ `${ mapType }Range` ][ 0 ] !== value[ 0 ] || material[ `${ mapType }Range` ][ 1 ] !== value[ 1 ] ) {
|
|
169
|
+
|
|
170
|
+
editor.execute( new SetMaterialRangeCommand( editor, object, `${ mapType }Range`, value[ 0 ], value[ 1 ], materialSlot ) );
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function update( currentObject, currentMaterialSlot = 0 ) {
|
|
177
|
+
|
|
178
|
+
object = currentObject;
|
|
179
|
+
materialSlot = currentMaterialSlot;
|
|
180
|
+
|
|
181
|
+
if ( object === null ) return;
|
|
182
|
+
if ( object.material === undefined ) return;
|
|
183
|
+
|
|
184
|
+
material = editor.getObjectMaterial( object, materialSlot );
|
|
185
|
+
|
|
186
|
+
if ( property in material ) {
|
|
187
|
+
|
|
188
|
+
if ( material[ property ] !== null ) {
|
|
189
|
+
|
|
190
|
+
map.setValue( material[ property ] );
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
enabled.setValue( material[ property ] !== null );
|
|
195
|
+
enabled.setDisabled( map.getValue() === null );
|
|
196
|
+
|
|
197
|
+
if ( intensity !== undefined ) {
|
|
198
|
+
|
|
199
|
+
intensity.setValue( material[ `${ property }Intensity` ] );
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if ( scale !== undefined ) {
|
|
204
|
+
|
|
205
|
+
scale.setValue( material[ `${ mapType }Scale` ] );
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if ( scaleX !== undefined ) {
|
|
210
|
+
|
|
211
|
+
scaleX.setValue( material[ `${ mapType }Scale` ].x );
|
|
212
|
+
scaleY.setValue( material[ `${ mapType }Scale` ].y );
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if ( rangeMin !== undefined ) {
|
|
217
|
+
|
|
218
|
+
rangeMin.setValue( material[ `${ mapType }Range` ][ 0 ] );
|
|
219
|
+
rangeMax.setValue( material[ `${ mapType }Range` ][ 1 ] );
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
container.setDisplay( '' );
|
|
224
|
+
|
|
225
|
+
} else {
|
|
226
|
+
|
|
227
|
+
container.setDisplay( 'none' );
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
//
|
|
234
|
+
|
|
235
|
+
signals.objectSelected.add( function ( selected ) {
|
|
236
|
+
|
|
237
|
+
map.setValue( null );
|
|
238
|
+
|
|
239
|
+
update( selected );
|
|
240
|
+
|
|
241
|
+
} );
|
|
242
|
+
|
|
243
|
+
signals.materialChanged.add( update );
|
|
244
|
+
|
|
245
|
+
return container;
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export { SidebarMaterialMapProperty };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { UINumber, UIRow, UIText } from './libs/ui.js';
|
|
2
|
+
import { SetMaterialValueCommand } from './commands/SetMaterialValueCommand.js';
|
|
3
|
+
|
|
4
|
+
function SidebarMaterialNumberProperty( editor, property, name, range = [ - Infinity, Infinity ], precision = 2 ) {
|
|
5
|
+
|
|
6
|
+
const signals = editor.signals;
|
|
7
|
+
|
|
8
|
+
const container = new UIRow();
|
|
9
|
+
container.add( new UIText( name ).setClass( 'Label' ) );
|
|
10
|
+
|
|
11
|
+
const number = new UINumber().setWidth( '60px' ).setRange( range[ 0 ], range[ 1 ] ).setPrecision( precision ).onChange( onChange );
|
|
12
|
+
container.add( number );
|
|
13
|
+
|
|
14
|
+
let object = null;
|
|
15
|
+
let materialSlot = null;
|
|
16
|
+
let material = null;
|
|
17
|
+
|
|
18
|
+
function onChange() {
|
|
19
|
+
|
|
20
|
+
if ( material[ property ] !== number.getValue() ) {
|
|
21
|
+
|
|
22
|
+
editor.execute( new SetMaterialValueCommand( editor, object, property, number.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
|
+
number.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 { SidebarMaterialNumberProperty };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { UIButton, UIRow, UIText } from './libs/ui.js';
|
|
2
|
+
|
|
3
|
+
function SidebarMaterialProgram( editor, property ) {
|
|
4
|
+
|
|
5
|
+
const signals = editor.signals;
|
|
6
|
+
const strings = editor.strings;
|
|
7
|
+
|
|
8
|
+
let object = null;
|
|
9
|
+
let materialSlot = null;
|
|
10
|
+
let material = null;
|
|
11
|
+
|
|
12
|
+
const container = new UIRow();
|
|
13
|
+
container.add( new UIText( strings.getKey( 'sidebar/material/program' ) ).setClass( 'Label' ) );
|
|
14
|
+
|
|
15
|
+
const programInfo = new UIButton( strings.getKey( 'sidebar/material/info' ) );
|
|
16
|
+
programInfo.setMarginRight( '4px' );
|
|
17
|
+
programInfo.onClick( function () {
|
|
18
|
+
|
|
19
|
+
signals.editScript.dispatch( object, 'programInfo' );
|
|
20
|
+
|
|
21
|
+
} );
|
|
22
|
+
container.add( programInfo );
|
|
23
|
+
|
|
24
|
+
const programVertex = new UIButton( strings.getKey( 'sidebar/material/vertex' ) );
|
|
25
|
+
programVertex.setMarginRight( '4px' );
|
|
26
|
+
programVertex.onClick( function () {
|
|
27
|
+
|
|
28
|
+
signals.editScript.dispatch( object, 'vertexShader' );
|
|
29
|
+
|
|
30
|
+
} );
|
|
31
|
+
container.add( programVertex );
|
|
32
|
+
|
|
33
|
+
const programFragment = new UIButton( strings.getKey( 'sidebar/material/fragment' ) );
|
|
34
|
+
programFragment.setMarginRight( '4px' );
|
|
35
|
+
programFragment.onClick( function () {
|
|
36
|
+
|
|
37
|
+
signals.editScript.dispatch( object, 'fragmentShader' );
|
|
38
|
+
|
|
39
|
+
} );
|
|
40
|
+
container.add( programFragment );
|
|
41
|
+
|
|
42
|
+
function update( currentObject, currentMaterialSlot = 0 ) {
|
|
43
|
+
|
|
44
|
+
object = currentObject;
|
|
45
|
+
materialSlot = currentMaterialSlot;
|
|
46
|
+
|
|
47
|
+
if ( object === null ) return;
|
|
48
|
+
if ( object.material === undefined ) return;
|
|
49
|
+
|
|
50
|
+
material = editor.getObjectMaterial( object, materialSlot );
|
|
51
|
+
|
|
52
|
+
if ( property in material ) {
|
|
53
|
+
|
|
54
|
+
container.setDisplay( '' );
|
|
55
|
+
|
|
56
|
+
} else {
|
|
57
|
+
|
|
58
|
+
container.setDisplay( 'none' );
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//
|
|
65
|
+
|
|
66
|
+
signals.objectSelected.add( update );
|
|
67
|
+
signals.materialChanged.add( update );
|
|
68
|
+
|
|
69
|
+
return container;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { SidebarMaterialProgram };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { UINumber, UIRow, UIText } from './libs/ui.js';
|
|
2
|
+
import { SetMaterialRangeCommand } from './commands/SetMaterialRangeCommand.js';
|
|
3
|
+
|
|
4
|
+
function SidebarMaterialRangeValueProperty( editor, property, name, isMin, range = [ - Infinity, Infinity ], precision = 2, step = 1, nudge = 0.01, unit = '' ) {
|
|
5
|
+
|
|
6
|
+
const signals = editor.signals;
|
|
7
|
+
|
|
8
|
+
const container = new UIRow();
|
|
9
|
+
container.add( new UIText( name ).setClass( 'Label' ) );
|
|
10
|
+
|
|
11
|
+
const number = new UINumber().setWidth( '60px' ).setRange( range[ 0 ], range[ 1 ] ).setPrecision( precision ).setStep( step ).setNudge( nudge ).setUnit( unit ).onChange( onChange );
|
|
12
|
+
container.add( number );
|
|
13
|
+
|
|
14
|
+
let object = null;
|
|
15
|
+
let materialSlot = null;
|
|
16
|
+
let material = null;
|
|
17
|
+
|
|
18
|
+
function onChange() {
|
|
19
|
+
|
|
20
|
+
if ( material[ property ][ isMin ? 0 : 1 ] !== number.getValue() ) {
|
|
21
|
+
|
|
22
|
+
const minValue = isMin ? number.getValue() : material[ property ][ 0 ];
|
|
23
|
+
const maxValue = isMin ? material[ property ][ 1 ] : number.getValue();
|
|
24
|
+
|
|
25
|
+
editor.execute( new SetMaterialRangeCommand( editor, object, property, minValue, maxValue, materialSlot ) );
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function update( currentObject, currentMaterialSlot = 0 ) {
|
|
32
|
+
|
|
33
|
+
object = currentObject;
|
|
34
|
+
materialSlot = currentMaterialSlot;
|
|
35
|
+
|
|
36
|
+
if ( object === null ) return;
|
|
37
|
+
if ( object.material === undefined ) return;
|
|
38
|
+
|
|
39
|
+
material = editor.getObjectMaterial( object, materialSlot );
|
|
40
|
+
|
|
41
|
+
if ( property in material ) {
|
|
42
|
+
|
|
43
|
+
number.setValue( material[ property ][ isMin ? 0 : 1 ] );
|
|
44
|
+
container.setDisplay( '' );
|
|
45
|
+
|
|
46
|
+
} else {
|
|
47
|
+
|
|
48
|
+
container.setDisplay( 'none' );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//
|
|
55
|
+
|
|
56
|
+
signals.objectSelected.add( update );
|
|
57
|
+
signals.materialChanged.add( update );
|
|
58
|
+
|
|
59
|
+
return container;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { SidebarMaterialRangeValueProperty };
|