mage-engine 3.25.6 → 3.25.8
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/dist/mage.js +1039 -42
- package/package.json +1 -1
package/dist/mage.js
CHANGED
|
@@ -56057,6 +56057,34 @@ const parseBoundingBoxSize = (boundingBox = {}) => {
|
|
|
56057
56057
|
};
|
|
56058
56058
|
}
|
|
56059
56059
|
};
|
|
56060
|
+
|
|
56061
|
+
/**
|
|
56062
|
+
* Compute the world-space AABB size for a body using Box3.setFromObject().
|
|
56063
|
+
* Returns { width, height, length } or null if the box is degenerate (all zeros).
|
|
56064
|
+
*/
|
|
56065
|
+
const getWorldBoundingBoxSize = body => {
|
|
56066
|
+
const worldBox = new Box3().setFromObject(body);
|
|
56067
|
+
const worldSize = new Vector3$1();
|
|
56068
|
+
worldBox.getSize(worldSize);
|
|
56069
|
+
if (worldSize.x === 0 && worldSize.y === 0 && worldSize.z === 0) {
|
|
56070
|
+
return null;
|
|
56071
|
+
}
|
|
56072
|
+
return {
|
|
56073
|
+
width: worldSize.x,
|
|
56074
|
+
height: worldSize.y,
|
|
56075
|
+
length: worldSize.z
|
|
56076
|
+
};
|
|
56077
|
+
};
|
|
56078
|
+
|
|
56079
|
+
/**
|
|
56080
|
+
* Derive a bounding sphere radius from the world-space AABB.
|
|
56081
|
+
* Returns the radius (half the longest axis) or null if the box is degenerate.
|
|
56082
|
+
*/
|
|
56083
|
+
const getWorldBoundingSphereRadius = body => {
|
|
56084
|
+
const size = getWorldBoundingBoxSize(body);
|
|
56085
|
+
if (!size) return null;
|
|
56086
|
+
return Math.max(size.width, size.height, size.length) / 2;
|
|
56087
|
+
};
|
|
56060
56088
|
const extractPositionAndQuaternion$1 = element => {
|
|
56061
56089
|
const {
|
|
56062
56090
|
x,
|
|
@@ -56099,29 +56127,24 @@ const extractBoxDescription = element => {
|
|
|
56099
56127
|
// More accurate for imported models whose geometry may be offset from the
|
|
56100
56128
|
// element origin, but can produce unexpected results for complex hierarchies.
|
|
56101
56129
|
const extractWorldBoxDescription = element => {
|
|
56102
|
-
const
|
|
56103
|
-
const worldBox = new Box3().setFromObject(body);
|
|
56104
|
-
const worldSize = new Vector3$1();
|
|
56105
|
-
worldBox.getSize(worldSize);
|
|
56130
|
+
const size = getWorldBoundingBoxSize(element.getBody());
|
|
56106
56131
|
|
|
56107
56132
|
// Fall back to the legacy path if the world box is degenerate.
|
|
56108
|
-
if (
|
|
56133
|
+
if (!size) {
|
|
56109
56134
|
return extractBoxDescription(element);
|
|
56110
56135
|
}
|
|
56111
56136
|
return {
|
|
56112
|
-
|
|
56113
|
-
height: worldSize.y,
|
|
56114
|
-
length: worldSize.z,
|
|
56137
|
+
...size,
|
|
56115
56138
|
size: {
|
|
56116
|
-
x:
|
|
56117
|
-
y:
|
|
56118
|
-
z:
|
|
56139
|
+
x: size.width,
|
|
56140
|
+
y: size.height,
|
|
56141
|
+
z: size.length
|
|
56119
56142
|
},
|
|
56120
56143
|
...extractPositionAndQuaternion$1(element)
|
|
56121
56144
|
};
|
|
56122
56145
|
};
|
|
56123
56146
|
const extractSphereDescription = element => {
|
|
56124
|
-
const radius = element.boundingSphere.radius;
|
|
56147
|
+
const radius = getWorldBoundingSphereRadius(element.getBody()) ?? element.boundingSphere.radius;
|
|
56125
56148
|
return {
|
|
56126
56149
|
radius,
|
|
56127
56150
|
...extractPositionAndQuaternion$1(element)
|
|
@@ -56140,7 +56163,7 @@ const getSphereDescriptionForElement = element => ({
|
|
|
56140
56163
|
});
|
|
56141
56164
|
const getPlayerDescriptionForElement = element => ({
|
|
56142
56165
|
...DEFAULT_PLAYER_DESCRIPTION,
|
|
56143
|
-
...
|
|
56166
|
+
...extractWorldBoxDescription(element)
|
|
56144
56167
|
});
|
|
56145
56168
|
const mapColliderTypeToDescription$1 = (colliderType = COLLIDER_TYPES$2.BOX) => ({
|
|
56146
56169
|
[COLLIDER_TYPES$2.BOX]: getBoxDescriptionForElement$1,
|
|
@@ -56179,7 +56202,7 @@ const convertAmmoVector = ({
|
|
|
56179
56202
|
x: z,
|
|
56180
56203
|
y,
|
|
56181
56204
|
z: x
|
|
56182
|
-
});var physicsUtils=/*#__PURE__*/Object.freeze({__proto__:null,DEFAULT_DESCRIPTION:DEFAULT_DESCRIPTION$1,mapColliderTypeToAddEvent:mapColliderTypeToAddEvent$1,extractBoundingBox:extractBoundingBox,extractBiggestBoundingBox:extractBiggestBoundingBox,extractBoundingSphere:extractBoundingSphere,extractBiggestBoundingSphere:extractBiggestBoundingSphere,parseBoundingBoxSize:parseBoundingBoxSize,extractPositionAndQuaternion:extractPositionAndQuaternion$1,extractBoxDescription:extractBoxDescription,extractSphereDescription:extractSphereDescription,getBoxDescriptionForElement:getBoxDescriptionForElement$1,getSphereDescriptionForElement:getSphereDescriptionForElement,getPlayerDescriptionForElement:getPlayerDescriptionForElement,mapColliderTypeToDescription:mapColliderTypeToDescription$1,iterateGeometries:iterateGeometries$1,convertAmmoVector:convertAmmoVector});const getHostURL = () => `${document.location.protocol}//${document.location.host}`;
|
|
56205
|
+
});var physicsUtils=/*#__PURE__*/Object.freeze({__proto__:null,DEFAULT_DESCRIPTION:DEFAULT_DESCRIPTION$1,mapColliderTypeToAddEvent:mapColliderTypeToAddEvent$1,extractBoundingBox:extractBoundingBox,extractBiggestBoundingBox:extractBiggestBoundingBox,extractBoundingSphere:extractBoundingSphere,extractBiggestBoundingSphere:extractBiggestBoundingSphere,parseBoundingBoxSize:parseBoundingBoxSize,getWorldBoundingBoxSize:getWorldBoundingBoxSize,getWorldBoundingSphereRadius:getWorldBoundingSphereRadius,extractPositionAndQuaternion:extractPositionAndQuaternion$1,extractBoxDescription:extractBoxDescription,extractSphereDescription:extractSphereDescription,getBoxDescriptionForElement:getBoxDescriptionForElement$1,getSphereDescriptionForElement:getSphereDescriptionForElement,getPlayerDescriptionForElement:getPlayerDescriptionForElement,mapColliderTypeToDescription:mapColliderTypeToDescription$1,iterateGeometries:iterateGeometries$1,convertAmmoVector:convertAmmoVector});const getHostURL = () => `${document.location.protocol}//${document.location.host}`;
|
|
56183
56206
|
const {
|
|
56184
56207
|
COLLIDER_TYPES: COLLIDER_TYPES$1
|
|
56185
56208
|
} = PHYSICS_CONSTANTS;
|
|
@@ -56520,13 +56543,22 @@ let Physics = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
56520
56543
|
value: function add(element, options = {}) {
|
|
56521
56544
|
if (Config$1.physics().enabled) {
|
|
56522
56545
|
const {
|
|
56523
|
-
colliderType = COLLIDER_TYPES$1.BOX
|
|
56546
|
+
colliderType = COLLIDER_TYPES$1.BOX,
|
|
56547
|
+
colliderWidth,
|
|
56548
|
+
colliderHeight,
|
|
56549
|
+
colliderLength,
|
|
56550
|
+
colliderRadius,
|
|
56551
|
+
...rest
|
|
56524
56552
|
} = options;
|
|
56525
56553
|
const uuid = element.uuid();
|
|
56526
56554
|
const description = {
|
|
56527
56555
|
...mapColliderTypeToDescription(colliderType)(element),
|
|
56528
|
-
...
|
|
56556
|
+
...rest
|
|
56529
56557
|
};
|
|
56558
|
+
if (colliderWidth != null) description.width = colliderWidth;
|
|
56559
|
+
if (colliderHeight != null) description.height = colliderHeight;
|
|
56560
|
+
if (colliderLength != null) description.length = colliderLength;
|
|
56561
|
+
if (colliderRadius != null) description.radius = colliderRadius;
|
|
56530
56562
|
this.storeElement(element, options);
|
|
56531
56563
|
this.worker.postMessage({
|
|
56532
56564
|
event: mapColliderTypeToAddEvent(description.collider),
|
|
@@ -58125,10 +58157,11 @@ var Physics$1 = new Physics();let Orbit = /*#__PURE__*/function (_EventDispatche
|
|
|
58125
58157
|
_this.gizmo = new Gizmo();
|
|
58126
58158
|
_this.plane = new TransformControlsPlane();
|
|
58127
58159
|
|
|
58128
|
-
// Set gizmo and plane to layer
|
|
58129
|
-
//
|
|
58130
|
-
|
|
58131
|
-
_this.
|
|
58160
|
+
// Set gizmo and plane to layer 2 ONLY so they render in a dedicated pass
|
|
58161
|
+
// on top of everything (sky, post-processing, etc.)
|
|
58162
|
+
// Layer 1 = editor helpers (togglable), Layer 2 = gizmo (always visible)
|
|
58163
|
+
_this.gizmo.layers.set(2);
|
|
58164
|
+
_this.plane.layers.set(2);
|
|
58132
58165
|
|
|
58133
58166
|
// Helper function to set depth properties on materials
|
|
58134
58167
|
const setMaterialDepth = material => {
|
|
@@ -58142,15 +58175,15 @@ var Physics$1 = new Physics();let Orbit = /*#__PURE__*/function (_EventDispatche
|
|
|
58142
58175
|
});
|
|
58143
58176
|
};
|
|
58144
58177
|
|
|
58145
|
-
// Also set layer
|
|
58146
|
-
//
|
|
58178
|
+
// Also set layer 2 on all children recursively
|
|
58179
|
+
// Disable depthTest so gizmos render on top of everything
|
|
58147
58180
|
_this.gizmo.traverse(child => {
|
|
58148
|
-
child.layers.set(
|
|
58181
|
+
child.layers.set(2);
|
|
58149
58182
|
child.renderOrder = 999;
|
|
58150
58183
|
setMaterialDepth(child.material);
|
|
58151
58184
|
});
|
|
58152
58185
|
_this.plane.traverse(child => {
|
|
58153
|
-
child.layers.set(
|
|
58186
|
+
child.layers.set(2);
|
|
58154
58187
|
child.renderOrder = 999;
|
|
58155
58188
|
setMaterialDepth(child.material);
|
|
58156
58189
|
});
|
|
@@ -58191,8 +58224,8 @@ var Physics$1 = new Physics();let Orbit = /*#__PURE__*/function (_EventDispatche
|
|
|
58191
58224
|
_this.setAndDispatch("showY", true);
|
|
58192
58225
|
_this.setAndDispatch("showZ", true);
|
|
58193
58226
|
_this.ray = new Raycaster();
|
|
58194
|
-
// Enable layer
|
|
58195
|
-
_this.ray.layers.enable(
|
|
58227
|
+
// Enable layer 2 so raycaster can pick gizmo objects (which are on layer 2)
|
|
58228
|
+
_this.ray.layers.enable(2);
|
|
58196
58229
|
_this._tempVector = new Vector3$1();
|
|
58197
58230
|
_this._tempVector2 = new Vector3$1();
|
|
58198
58231
|
_this._tempQuaternion = new Quaternion();
|
|
@@ -60103,10 +60136,12 @@ var Controls$1 = new Controls();let Scene = /*#__PURE__*/function () {
|
|
|
60103
60136
|
key: "createCamera",
|
|
60104
60137
|
value: function createCamera(camera) {
|
|
60105
60138
|
this.camera = camera;
|
|
60106
|
-
// Enable layer 1 so camera can see editor-only objects (helpers, grid
|
|
60139
|
+
// Enable layer 1 so camera can see editor-only objects (helpers, grid)
|
|
60140
|
+
// Enable layer 2 so camera can see gizmos (rendered in separate pass)
|
|
60107
60141
|
// Mirror cameras only use layer 0, so they won't render these
|
|
60108
60142
|
if (this.camera && this.camera.getBody()) {
|
|
60109
60143
|
this.camera.getBody().layers.enable(1);
|
|
60144
|
+
this.camera.getBody().layers.enable(2);
|
|
60110
60145
|
}
|
|
60111
60146
|
}
|
|
60112
60147
|
}, {
|
|
@@ -60204,6 +60239,53 @@ var Controls$1 = new Controls();let Scene = /*#__PURE__*/function () {
|
|
|
60204
60239
|
this.renderer.setRenderTarget(null);
|
|
60205
60240
|
this.renderer.render(this.scene, this.camera.getBody());
|
|
60206
60241
|
}
|
|
60242
|
+
|
|
60243
|
+
// Render gizmo layer (layer 2) on top of everything.
|
|
60244
|
+
// Called after main render or post-processing to ensure gizmos are always visible
|
|
60245
|
+
// regardless of sky, post-processing, or sortObjects setting.
|
|
60246
|
+
}, {
|
|
60247
|
+
key: "renderGizmoLayer",
|
|
60248
|
+
value: function renderGizmoLayer() {
|
|
60249
|
+
if (!this.renderer || !this.camera) return;
|
|
60250
|
+
const cameraBody = this.camera.getBody();
|
|
60251
|
+
|
|
60252
|
+
// Save current camera layer mask
|
|
60253
|
+
const savedLayers = cameraBody.layers.mask;
|
|
60254
|
+
|
|
60255
|
+
// Set camera to only see layer 2 (gizmo layer)
|
|
60256
|
+
cameraBody.layers.set(2);
|
|
60257
|
+
|
|
60258
|
+
// Ensure we render to screen (not a post-processing buffer)
|
|
60259
|
+
this.renderer.setRenderTarget(null);
|
|
60260
|
+
// Clear only depth so gizmo renders on top of the already-drawn frame
|
|
60261
|
+
this.renderer.autoClear = false;
|
|
60262
|
+
this.renderer.clearDepth();
|
|
60263
|
+
this.renderer.render(this.scene, cameraBody);
|
|
60264
|
+
this.renderer.autoClear = true;
|
|
60265
|
+
|
|
60266
|
+
// Restore camera layers
|
|
60267
|
+
cameraBody.layers.mask = savedLayers;
|
|
60268
|
+
}
|
|
60269
|
+
|
|
60270
|
+
// Toggle editor helpers visibility (layer 1: grid, light helpers, camera helpers)
|
|
60271
|
+
// Does NOT affect gizmos (layer 2) which are always visible
|
|
60272
|
+
}, {
|
|
60273
|
+
key: "setHelpersVisible",
|
|
60274
|
+
value: function setHelpersVisible(visible) {
|
|
60275
|
+
if (!this.camera || !this.camera.getBody()) return;
|
|
60276
|
+
const cameraBody = this.camera.getBody();
|
|
60277
|
+
if (visible) {
|
|
60278
|
+
cameraBody.layers.enable(1);
|
|
60279
|
+
} else {
|
|
60280
|
+
cameraBody.layers.disable(1);
|
|
60281
|
+
}
|
|
60282
|
+
this.helpersVisible = visible;
|
|
60283
|
+
}
|
|
60284
|
+
}, {
|
|
60285
|
+
key: "getHelpersVisible",
|
|
60286
|
+
value: function getHelpersVisible() {
|
|
60287
|
+
return this.helpersVisible !== false;
|
|
60288
|
+
}
|
|
60207
60289
|
}, {
|
|
60208
60290
|
key: "setFog",
|
|
60209
60291
|
value: function setFog(color, density) {
|
|
@@ -61301,7 +61383,7 @@ function applyMiddleware() {
|
|
|
61301
61383
|
|
|
61302
61384
|
var thunk = createThunkMiddleware();
|
|
61303
61385
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
61304
|
-
var version$1 = "3.25.
|
|
61386
|
+
var version$1 = "3.25.8";
|
|
61305
61387
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
61306
61388
|
var main = "dist/mage.js";
|
|
61307
61389
|
var author$1 = {
|
|
@@ -64742,6 +64824,33 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
|
|
|
64742
64824
|
setUpLightsAndShadows(this.getBody());
|
|
64743
64825
|
}
|
|
64744
64826
|
}
|
|
64827
|
+
}, {
|
|
64828
|
+
key: "getComputedColliderSize",
|
|
64829
|
+
value: function getComputedColliderSize() {
|
|
64830
|
+
const result = {};
|
|
64831
|
+
try {
|
|
64832
|
+
const body = this.getBody();
|
|
64833
|
+
const worldSize = body ? getWorldBoundingBoxSize(body) : null;
|
|
64834
|
+
if (worldSize) {
|
|
64835
|
+
result.width = parseFloat(worldSize.width.toFixed(3));
|
|
64836
|
+
result.height = parseFloat(worldSize.height.toFixed(3));
|
|
64837
|
+
result.length = parseFloat(worldSize.length.toFixed(3));
|
|
64838
|
+
result.radius = parseFloat(getWorldBoundingSphereRadius(body).toFixed(3));
|
|
64839
|
+
} else if (this.boundingBox) {
|
|
64840
|
+
const size = parseBoundingBoxSize(this.boundingBox);
|
|
64841
|
+
const scale = this.getScale();
|
|
64842
|
+
result.width = parseFloat((size.x * scale.x).toFixed(3));
|
|
64843
|
+
result.height = parseFloat((size.y * scale.y).toFixed(3));
|
|
64844
|
+
result.length = parseFloat((size.z * scale.z).toFixed(3));
|
|
64845
|
+
}
|
|
64846
|
+
if (result.radius == null && this.boundingSphere) {
|
|
64847
|
+
result.radius = parseFloat(this.boundingSphere.radius.toFixed(3));
|
|
64848
|
+
}
|
|
64849
|
+
} catch {
|
|
64850
|
+
// bounding box/sphere not yet available
|
|
64851
|
+
}
|
|
64852
|
+
return result;
|
|
64853
|
+
}
|
|
64745
64854
|
}, {
|
|
64746
64855
|
key: "addToScene",
|
|
64747
64856
|
value: function addToScene() {
|
|
@@ -65675,7 +65784,8 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
|
|
|
65675
65784
|
..._superPropGet(Element, "toJSON", this, 3)([parseJSON]),
|
|
65676
65785
|
// Physics options (state is not used by Importer, only options)
|
|
65677
65786
|
physics: {
|
|
65678
|
-
options: this.getPhysicsOptions()
|
|
65787
|
+
options: this.getPhysicsOptions(),
|
|
65788
|
+
computedSize: this.getComputedColliderSize()
|
|
65679
65789
|
},
|
|
65680
65790
|
// Textures with serialized map
|
|
65681
65791
|
textures: serializeMap(this.textures),
|
|
@@ -92772,6 +92882,11 @@ let Level = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
92772
92882
|
} else {
|
|
92773
92883
|
Scene$1.render(dt);
|
|
92774
92884
|
}
|
|
92885
|
+
|
|
92886
|
+
// Render gizmo layer on top of everything (separate pass with depth clear)
|
|
92887
|
+
// This ensures gizmos are always visible regardless of sky, post-processing,
|
|
92888
|
+
// or the sortObjects=false setting used when shadows are enabled.
|
|
92889
|
+
Scene$1.renderGizmoLayer();
|
|
92775
92890
|
Particles$1.update(dt);
|
|
92776
92891
|
this.onUpdate(dt);
|
|
92777
92892
|
Scene$1.update(dt);
|
|
@@ -98062,7 +98177,877 @@ let Sound = /*#__PURE__*/function (_Entity) {
|
|
|
98062
98177
|
});
|
|
98063
98178
|
}
|
|
98064
98179
|
}]);
|
|
98065
|
-
}(Entity);
|
|
98180
|
+
}(Entity);var LineSegmentsGeometry = function () {
|
|
98181
|
+
|
|
98182
|
+
InstancedBufferGeometry.call( this );
|
|
98183
|
+
|
|
98184
|
+
this.type = 'LineSegmentsGeometry';
|
|
98185
|
+
|
|
98186
|
+
var positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ];
|
|
98187
|
+
var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];
|
|
98188
|
+
var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];
|
|
98189
|
+
|
|
98190
|
+
this.setIndex( index );
|
|
98191
|
+
this.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
|
|
98192
|
+
this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
|
98193
|
+
|
|
98194
|
+
};
|
|
98195
|
+
|
|
98196
|
+
LineSegmentsGeometry.prototype = Object.assign( Object.create( InstancedBufferGeometry.prototype ), {
|
|
98197
|
+
|
|
98198
|
+
constructor: LineSegmentsGeometry,
|
|
98199
|
+
|
|
98200
|
+
isLineSegmentsGeometry: true,
|
|
98201
|
+
|
|
98202
|
+
applyMatrix4: function ( matrix ) {
|
|
98203
|
+
|
|
98204
|
+
var start = this.attributes.instanceStart;
|
|
98205
|
+
var end = this.attributes.instanceEnd;
|
|
98206
|
+
|
|
98207
|
+
if ( start !== undefined ) {
|
|
98208
|
+
|
|
98209
|
+
start.applyMatrix4( matrix );
|
|
98210
|
+
|
|
98211
|
+
end.applyMatrix4( matrix );
|
|
98212
|
+
|
|
98213
|
+
start.needsUpdate = true;
|
|
98214
|
+
|
|
98215
|
+
}
|
|
98216
|
+
|
|
98217
|
+
if ( this.boundingBox !== null ) {
|
|
98218
|
+
|
|
98219
|
+
this.computeBoundingBox();
|
|
98220
|
+
|
|
98221
|
+
}
|
|
98222
|
+
|
|
98223
|
+
if ( this.boundingSphere !== null ) {
|
|
98224
|
+
|
|
98225
|
+
this.computeBoundingSphere();
|
|
98226
|
+
|
|
98227
|
+
}
|
|
98228
|
+
|
|
98229
|
+
return this;
|
|
98230
|
+
|
|
98231
|
+
},
|
|
98232
|
+
|
|
98233
|
+
setPositions: function ( array ) {
|
|
98234
|
+
|
|
98235
|
+
var lineSegments;
|
|
98236
|
+
|
|
98237
|
+
if ( array instanceof Float32Array ) {
|
|
98238
|
+
|
|
98239
|
+
lineSegments = array;
|
|
98240
|
+
|
|
98241
|
+
} else if ( Array.isArray( array ) ) {
|
|
98242
|
+
|
|
98243
|
+
lineSegments = new Float32Array( array );
|
|
98244
|
+
|
|
98245
|
+
}
|
|
98246
|
+
|
|
98247
|
+
var instanceBuffer = new InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz
|
|
98248
|
+
|
|
98249
|
+
this.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
|
|
98250
|
+
this.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
|
|
98251
|
+
|
|
98252
|
+
//
|
|
98253
|
+
|
|
98254
|
+
this.computeBoundingBox();
|
|
98255
|
+
this.computeBoundingSphere();
|
|
98256
|
+
|
|
98257
|
+
return this;
|
|
98258
|
+
|
|
98259
|
+
},
|
|
98260
|
+
|
|
98261
|
+
setColors: function ( array ) {
|
|
98262
|
+
|
|
98263
|
+
var colors;
|
|
98264
|
+
|
|
98265
|
+
if ( array instanceof Float32Array ) {
|
|
98266
|
+
|
|
98267
|
+
colors = array;
|
|
98268
|
+
|
|
98269
|
+
} else if ( Array.isArray( array ) ) {
|
|
98270
|
+
|
|
98271
|
+
colors = new Float32Array( array );
|
|
98272
|
+
|
|
98273
|
+
}
|
|
98274
|
+
|
|
98275
|
+
var instanceColorBuffer = new InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb
|
|
98276
|
+
|
|
98277
|
+
this.setAttribute( 'instanceColorStart', new InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb
|
|
98278
|
+
this.setAttribute( 'instanceColorEnd', new InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb
|
|
98279
|
+
|
|
98280
|
+
return this;
|
|
98281
|
+
|
|
98282
|
+
},
|
|
98283
|
+
|
|
98284
|
+
fromWireframeGeometry: function ( geometry ) {
|
|
98285
|
+
|
|
98286
|
+
this.setPositions( geometry.attributes.position.array );
|
|
98287
|
+
|
|
98288
|
+
return this;
|
|
98289
|
+
|
|
98290
|
+
},
|
|
98291
|
+
|
|
98292
|
+
fromEdgesGeometry: function ( geometry ) {
|
|
98293
|
+
|
|
98294
|
+
this.setPositions( geometry.attributes.position.array );
|
|
98295
|
+
|
|
98296
|
+
return this;
|
|
98297
|
+
|
|
98298
|
+
},
|
|
98299
|
+
|
|
98300
|
+
fromMesh: function ( mesh ) {
|
|
98301
|
+
|
|
98302
|
+
this.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );
|
|
98303
|
+
|
|
98304
|
+
// set colors, maybe
|
|
98305
|
+
|
|
98306
|
+
return this;
|
|
98307
|
+
|
|
98308
|
+
},
|
|
98309
|
+
|
|
98310
|
+
fromLineSegments: function ( lineSegments ) {
|
|
98311
|
+
|
|
98312
|
+
var geometry = lineSegments.geometry;
|
|
98313
|
+
|
|
98314
|
+
if ( geometry.isGeometry ) {
|
|
98315
|
+
|
|
98316
|
+
console.error( 'THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.' );
|
|
98317
|
+
return;
|
|
98318
|
+
|
|
98319
|
+
} else if ( geometry.isBufferGeometry ) {
|
|
98320
|
+
|
|
98321
|
+
this.setPositions( geometry.attributes.position.array ); // assumes non-indexed
|
|
98322
|
+
|
|
98323
|
+
}
|
|
98324
|
+
|
|
98325
|
+
// set colors, maybe
|
|
98326
|
+
|
|
98327
|
+
return this;
|
|
98328
|
+
|
|
98329
|
+
},
|
|
98330
|
+
|
|
98331
|
+
computeBoundingBox: function () {
|
|
98332
|
+
|
|
98333
|
+
var box = new Box3();
|
|
98334
|
+
|
|
98335
|
+
return function computeBoundingBox() {
|
|
98336
|
+
|
|
98337
|
+
if ( this.boundingBox === null ) {
|
|
98338
|
+
|
|
98339
|
+
this.boundingBox = new Box3();
|
|
98340
|
+
|
|
98341
|
+
}
|
|
98342
|
+
|
|
98343
|
+
var start = this.attributes.instanceStart;
|
|
98344
|
+
var end = this.attributes.instanceEnd;
|
|
98345
|
+
|
|
98346
|
+
if ( start !== undefined && end !== undefined ) {
|
|
98347
|
+
|
|
98348
|
+
this.boundingBox.setFromBufferAttribute( start );
|
|
98349
|
+
|
|
98350
|
+
box.setFromBufferAttribute( end );
|
|
98351
|
+
|
|
98352
|
+
this.boundingBox.union( box );
|
|
98353
|
+
|
|
98354
|
+
}
|
|
98355
|
+
|
|
98356
|
+
};
|
|
98357
|
+
|
|
98358
|
+
}(),
|
|
98359
|
+
|
|
98360
|
+
computeBoundingSphere: function () {
|
|
98361
|
+
|
|
98362
|
+
var vector = new Vector3$1();
|
|
98363
|
+
|
|
98364
|
+
return function computeBoundingSphere() {
|
|
98365
|
+
|
|
98366
|
+
if ( this.boundingSphere === null ) {
|
|
98367
|
+
|
|
98368
|
+
this.boundingSphere = new Sphere$1();
|
|
98369
|
+
|
|
98370
|
+
}
|
|
98371
|
+
|
|
98372
|
+
if ( this.boundingBox === null ) {
|
|
98373
|
+
|
|
98374
|
+
this.computeBoundingBox();
|
|
98375
|
+
|
|
98376
|
+
}
|
|
98377
|
+
|
|
98378
|
+
var start = this.attributes.instanceStart;
|
|
98379
|
+
var end = this.attributes.instanceEnd;
|
|
98380
|
+
|
|
98381
|
+
if ( start !== undefined && end !== undefined ) {
|
|
98382
|
+
|
|
98383
|
+
var center = this.boundingSphere.center;
|
|
98384
|
+
|
|
98385
|
+
this.boundingBox.getCenter( center );
|
|
98386
|
+
|
|
98387
|
+
var maxRadiusSq = 0;
|
|
98388
|
+
|
|
98389
|
+
for ( var i = 0, il = start.count; i < il; i ++ ) {
|
|
98390
|
+
|
|
98391
|
+
vector.fromBufferAttribute( start, i );
|
|
98392
|
+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
|
|
98393
|
+
|
|
98394
|
+
vector.fromBufferAttribute( end, i );
|
|
98395
|
+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
|
|
98396
|
+
|
|
98397
|
+
}
|
|
98398
|
+
|
|
98399
|
+
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
|
|
98400
|
+
|
|
98401
|
+
if ( isNaN( this.boundingSphere.radius ) ) {
|
|
98402
|
+
|
|
98403
|
+
console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );
|
|
98404
|
+
|
|
98405
|
+
}
|
|
98406
|
+
|
|
98407
|
+
}
|
|
98408
|
+
|
|
98409
|
+
};
|
|
98410
|
+
|
|
98411
|
+
}(),
|
|
98412
|
+
|
|
98413
|
+
toJSON: function () {
|
|
98414
|
+
|
|
98415
|
+
// todo
|
|
98416
|
+
|
|
98417
|
+
},
|
|
98418
|
+
|
|
98419
|
+
applyMatrix: function ( matrix ) {
|
|
98420
|
+
|
|
98421
|
+
console.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );
|
|
98422
|
+
|
|
98423
|
+
return this.applyMatrix4( matrix );
|
|
98424
|
+
|
|
98425
|
+
}
|
|
98426
|
+
|
|
98427
|
+
} );/**
|
|
98428
|
+
* parameters = {
|
|
98429
|
+
* color: <hex>,
|
|
98430
|
+
* linewidth: <float>,
|
|
98431
|
+
* dashed: <boolean>,
|
|
98432
|
+
* dashScale: <float>,
|
|
98433
|
+
* dashSize: <float>,
|
|
98434
|
+
* dashOffset: <float>,
|
|
98435
|
+
* gapSize: <float>,
|
|
98436
|
+
* resolution: <Vector2>, // to be set by renderer
|
|
98437
|
+
* }
|
|
98438
|
+
*/
|
|
98439
|
+
|
|
98440
|
+
UniformsLib.line = {
|
|
98441
|
+
|
|
98442
|
+
linewidth: { value: 1 },
|
|
98443
|
+
resolution: { value: new Vector2( 1, 1 ) },
|
|
98444
|
+
dashScale: { value: 1 },
|
|
98445
|
+
dashSize: { value: 1 },
|
|
98446
|
+
dashOffset: { value: 0 },
|
|
98447
|
+
gapSize: { value: 1 }, // todo FIX - maybe change to totalSize
|
|
98448
|
+
opacity: { value: 1 }
|
|
98449
|
+
|
|
98450
|
+
};
|
|
98451
|
+
|
|
98452
|
+
ShaderLib[ 'line' ] = {
|
|
98453
|
+
|
|
98454
|
+
uniforms: UniformsUtils.merge( [
|
|
98455
|
+
UniformsLib.common,
|
|
98456
|
+
UniformsLib.fog,
|
|
98457
|
+
UniformsLib.line
|
|
98458
|
+
] ),
|
|
98459
|
+
|
|
98460
|
+
vertexShader:
|
|
98461
|
+
`
|
|
98462
|
+
#include <common>
|
|
98463
|
+
#include <color_pars_vertex>
|
|
98464
|
+
#include <fog_pars_vertex>
|
|
98465
|
+
#include <logdepthbuf_pars_vertex>
|
|
98466
|
+
#include <clipping_planes_pars_vertex>
|
|
98467
|
+
|
|
98468
|
+
uniform float linewidth;
|
|
98469
|
+
uniform vec2 resolution;
|
|
98470
|
+
|
|
98471
|
+
attribute vec3 instanceStart;
|
|
98472
|
+
attribute vec3 instanceEnd;
|
|
98473
|
+
|
|
98474
|
+
attribute vec3 instanceColorStart;
|
|
98475
|
+
attribute vec3 instanceColorEnd;
|
|
98476
|
+
|
|
98477
|
+
varying vec2 vUv;
|
|
98478
|
+
|
|
98479
|
+
#ifdef USE_DASH
|
|
98480
|
+
|
|
98481
|
+
uniform float dashScale;
|
|
98482
|
+
attribute float instanceDistanceStart;
|
|
98483
|
+
attribute float instanceDistanceEnd;
|
|
98484
|
+
varying float vLineDistance;
|
|
98485
|
+
|
|
98486
|
+
#endif
|
|
98487
|
+
|
|
98488
|
+
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|
98489
|
+
|
|
98490
|
+
// trim end segment so it terminates between the camera plane and the near plane
|
|
98491
|
+
|
|
98492
|
+
// conservative estimate of the near plane
|
|
98493
|
+
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
98494
|
+
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
98495
|
+
float nearEstimate = - 0.5 * b / a;
|
|
98496
|
+
|
|
98497
|
+
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
98498
|
+
|
|
98499
|
+
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
98500
|
+
|
|
98501
|
+
}
|
|
98502
|
+
|
|
98503
|
+
void main() {
|
|
98504
|
+
|
|
98505
|
+
#ifdef USE_COLOR
|
|
98506
|
+
|
|
98507
|
+
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
98508
|
+
|
|
98509
|
+
#endif
|
|
98510
|
+
|
|
98511
|
+
#ifdef USE_DASH
|
|
98512
|
+
|
|
98513
|
+
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
98514
|
+
|
|
98515
|
+
#endif
|
|
98516
|
+
|
|
98517
|
+
float aspect = resolution.x / resolution.y;
|
|
98518
|
+
|
|
98519
|
+
vUv = uv;
|
|
98520
|
+
|
|
98521
|
+
// camera space
|
|
98522
|
+
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
98523
|
+
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
98524
|
+
|
|
98525
|
+
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
98526
|
+
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
98527
|
+
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
98528
|
+
// perhaps there is a more elegant solution -- WestLangley
|
|
98529
|
+
|
|
98530
|
+
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
98531
|
+
|
|
98532
|
+
if ( perspective ) {
|
|
98533
|
+
|
|
98534
|
+
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
98535
|
+
|
|
98536
|
+
trimSegment( start, end );
|
|
98537
|
+
|
|
98538
|
+
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
98539
|
+
|
|
98540
|
+
trimSegment( end, start );
|
|
98541
|
+
|
|
98542
|
+
}
|
|
98543
|
+
|
|
98544
|
+
}
|
|
98545
|
+
|
|
98546
|
+
// clip space
|
|
98547
|
+
vec4 clipStart = projectionMatrix * start;
|
|
98548
|
+
vec4 clipEnd = projectionMatrix * end;
|
|
98549
|
+
|
|
98550
|
+
// ndc space
|
|
98551
|
+
vec2 ndcStart = clipStart.xy / clipStart.w;
|
|
98552
|
+
vec2 ndcEnd = clipEnd.xy / clipEnd.w;
|
|
98553
|
+
|
|
98554
|
+
// direction
|
|
98555
|
+
vec2 dir = ndcEnd - ndcStart;
|
|
98556
|
+
|
|
98557
|
+
// account for clip-space aspect ratio
|
|
98558
|
+
dir.x *= aspect;
|
|
98559
|
+
dir = normalize( dir );
|
|
98560
|
+
|
|
98561
|
+
// perpendicular to dir
|
|
98562
|
+
vec2 offset = vec2( dir.y, - dir.x );
|
|
98563
|
+
|
|
98564
|
+
// undo aspect ratio adjustment
|
|
98565
|
+
dir.x /= aspect;
|
|
98566
|
+
offset.x /= aspect;
|
|
98567
|
+
|
|
98568
|
+
// sign flip
|
|
98569
|
+
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
98570
|
+
|
|
98571
|
+
// endcaps
|
|
98572
|
+
if ( position.y < 0.0 ) {
|
|
98573
|
+
|
|
98574
|
+
offset += - dir;
|
|
98575
|
+
|
|
98576
|
+
} else if ( position.y > 1.0 ) {
|
|
98577
|
+
|
|
98578
|
+
offset += dir;
|
|
98579
|
+
|
|
98580
|
+
}
|
|
98581
|
+
|
|
98582
|
+
// adjust for linewidth
|
|
98583
|
+
offset *= linewidth;
|
|
98584
|
+
|
|
98585
|
+
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
98586
|
+
offset /= resolution.y;
|
|
98587
|
+
|
|
98588
|
+
// select end
|
|
98589
|
+
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
98590
|
+
|
|
98591
|
+
// back to clip space
|
|
98592
|
+
offset *= clip.w;
|
|
98593
|
+
|
|
98594
|
+
clip.xy += offset;
|
|
98595
|
+
|
|
98596
|
+
gl_Position = clip;
|
|
98597
|
+
|
|
98598
|
+
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
98599
|
+
|
|
98600
|
+
#include <logdepthbuf_vertex>
|
|
98601
|
+
#include <clipping_planes_vertex>
|
|
98602
|
+
#include <fog_vertex>
|
|
98603
|
+
|
|
98604
|
+
}
|
|
98605
|
+
`,
|
|
98606
|
+
|
|
98607
|
+
fragmentShader:
|
|
98608
|
+
`
|
|
98609
|
+
uniform vec3 diffuse;
|
|
98610
|
+
uniform float opacity;
|
|
98611
|
+
|
|
98612
|
+
#ifdef USE_DASH
|
|
98613
|
+
|
|
98614
|
+
uniform float dashSize;
|
|
98615
|
+
uniform float dashOffset;
|
|
98616
|
+
uniform float gapSize;
|
|
98617
|
+
|
|
98618
|
+
#endif
|
|
98619
|
+
|
|
98620
|
+
varying float vLineDistance;
|
|
98621
|
+
|
|
98622
|
+
#include <common>
|
|
98623
|
+
#include <color_pars_fragment>
|
|
98624
|
+
#include <fog_pars_fragment>
|
|
98625
|
+
#include <logdepthbuf_pars_fragment>
|
|
98626
|
+
#include <clipping_planes_pars_fragment>
|
|
98627
|
+
|
|
98628
|
+
varying vec2 vUv;
|
|
98629
|
+
|
|
98630
|
+
void main() {
|
|
98631
|
+
|
|
98632
|
+
#include <clipping_planes_fragment>
|
|
98633
|
+
|
|
98634
|
+
#ifdef USE_DASH
|
|
98635
|
+
|
|
98636
|
+
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
98637
|
+
|
|
98638
|
+
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
98639
|
+
|
|
98640
|
+
#endif
|
|
98641
|
+
|
|
98642
|
+
if ( abs( vUv.y ) > 1.0 ) {
|
|
98643
|
+
|
|
98644
|
+
float a = vUv.x;
|
|
98645
|
+
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
98646
|
+
float len2 = a * a + b * b;
|
|
98647
|
+
|
|
98648
|
+
if ( len2 > 1.0 ) discard;
|
|
98649
|
+
|
|
98650
|
+
}
|
|
98651
|
+
|
|
98652
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
98653
|
+
|
|
98654
|
+
#include <logdepthbuf_fragment>
|
|
98655
|
+
#include <color_fragment>
|
|
98656
|
+
|
|
98657
|
+
gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );
|
|
98658
|
+
|
|
98659
|
+
#include <tonemapping_fragment>
|
|
98660
|
+
#include <encodings_fragment>
|
|
98661
|
+
#include <fog_fragment>
|
|
98662
|
+
#include <premultiplied_alpha_fragment>
|
|
98663
|
+
|
|
98664
|
+
}
|
|
98665
|
+
`
|
|
98666
|
+
};
|
|
98667
|
+
|
|
98668
|
+
var LineMaterial = function ( parameters ) {
|
|
98669
|
+
|
|
98670
|
+
ShaderMaterial.call( this, {
|
|
98671
|
+
|
|
98672
|
+
type: 'LineMaterial',
|
|
98673
|
+
|
|
98674
|
+
uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
|
|
98675
|
+
|
|
98676
|
+
vertexShader: ShaderLib[ 'line' ].vertexShader,
|
|
98677
|
+
fragmentShader: ShaderLib[ 'line' ].fragmentShader,
|
|
98678
|
+
|
|
98679
|
+
clipping: true // required for clipping support
|
|
98680
|
+
|
|
98681
|
+
} );
|
|
98682
|
+
|
|
98683
|
+
this.dashed = false;
|
|
98684
|
+
|
|
98685
|
+
Object.defineProperties( this, {
|
|
98686
|
+
|
|
98687
|
+
color: {
|
|
98688
|
+
|
|
98689
|
+
enumerable: true,
|
|
98690
|
+
|
|
98691
|
+
get: function () {
|
|
98692
|
+
|
|
98693
|
+
return this.uniforms.diffuse.value;
|
|
98694
|
+
|
|
98695
|
+
},
|
|
98696
|
+
|
|
98697
|
+
set: function ( value ) {
|
|
98698
|
+
|
|
98699
|
+
this.uniforms.diffuse.value = value;
|
|
98700
|
+
|
|
98701
|
+
}
|
|
98702
|
+
|
|
98703
|
+
},
|
|
98704
|
+
|
|
98705
|
+
linewidth: {
|
|
98706
|
+
|
|
98707
|
+
enumerable: true,
|
|
98708
|
+
|
|
98709
|
+
get: function () {
|
|
98710
|
+
|
|
98711
|
+
return this.uniforms.linewidth.value;
|
|
98712
|
+
|
|
98713
|
+
},
|
|
98714
|
+
|
|
98715
|
+
set: function ( value ) {
|
|
98716
|
+
|
|
98717
|
+
this.uniforms.linewidth.value = value;
|
|
98718
|
+
|
|
98719
|
+
}
|
|
98720
|
+
|
|
98721
|
+
},
|
|
98722
|
+
|
|
98723
|
+
dashScale: {
|
|
98724
|
+
|
|
98725
|
+
enumerable: true,
|
|
98726
|
+
|
|
98727
|
+
get: function () {
|
|
98728
|
+
|
|
98729
|
+
return this.uniforms.dashScale.value;
|
|
98730
|
+
|
|
98731
|
+
},
|
|
98732
|
+
|
|
98733
|
+
set: function ( value ) {
|
|
98734
|
+
|
|
98735
|
+
this.uniforms.dashScale.value = value;
|
|
98736
|
+
|
|
98737
|
+
}
|
|
98738
|
+
|
|
98739
|
+
},
|
|
98740
|
+
|
|
98741
|
+
dashSize: {
|
|
98742
|
+
|
|
98743
|
+
enumerable: true,
|
|
98744
|
+
|
|
98745
|
+
get: function () {
|
|
98746
|
+
|
|
98747
|
+
return this.uniforms.dashSize.value;
|
|
98748
|
+
|
|
98749
|
+
},
|
|
98750
|
+
|
|
98751
|
+
set: function ( value ) {
|
|
98752
|
+
|
|
98753
|
+
this.uniforms.dashSize.value = value;
|
|
98754
|
+
|
|
98755
|
+
}
|
|
98756
|
+
|
|
98757
|
+
},
|
|
98758
|
+
|
|
98759
|
+
dashOffset: {
|
|
98760
|
+
|
|
98761
|
+
enumerable: true,
|
|
98762
|
+
|
|
98763
|
+
get: function () {
|
|
98764
|
+
|
|
98765
|
+
return this.uniforms.dashOffset.value;
|
|
98766
|
+
|
|
98767
|
+
},
|
|
98768
|
+
|
|
98769
|
+
set: function ( value ) {
|
|
98770
|
+
|
|
98771
|
+
this.uniforms.dashOffset.value = value;
|
|
98772
|
+
|
|
98773
|
+
}
|
|
98774
|
+
|
|
98775
|
+
},
|
|
98776
|
+
|
|
98777
|
+
gapSize: {
|
|
98778
|
+
|
|
98779
|
+
enumerable: true,
|
|
98780
|
+
|
|
98781
|
+
get: function () {
|
|
98782
|
+
|
|
98783
|
+
return this.uniforms.gapSize.value;
|
|
98784
|
+
|
|
98785
|
+
},
|
|
98786
|
+
|
|
98787
|
+
set: function ( value ) {
|
|
98788
|
+
|
|
98789
|
+
this.uniforms.gapSize.value = value;
|
|
98790
|
+
|
|
98791
|
+
}
|
|
98792
|
+
|
|
98793
|
+
},
|
|
98794
|
+
|
|
98795
|
+
opacity: {
|
|
98796
|
+
|
|
98797
|
+
enumerable: true,
|
|
98798
|
+
|
|
98799
|
+
get: function () {
|
|
98800
|
+
|
|
98801
|
+
return this.uniforms.opacity.value;
|
|
98802
|
+
|
|
98803
|
+
},
|
|
98804
|
+
|
|
98805
|
+
set: function ( value ) {
|
|
98806
|
+
|
|
98807
|
+
this.uniforms.opacity.value = value;
|
|
98808
|
+
|
|
98809
|
+
}
|
|
98810
|
+
|
|
98811
|
+
},
|
|
98812
|
+
|
|
98813
|
+
resolution: {
|
|
98814
|
+
|
|
98815
|
+
enumerable: true,
|
|
98816
|
+
|
|
98817
|
+
get: function () {
|
|
98818
|
+
|
|
98819
|
+
return this.uniforms.resolution.value;
|
|
98820
|
+
|
|
98821
|
+
},
|
|
98822
|
+
|
|
98823
|
+
set: function ( value ) {
|
|
98824
|
+
|
|
98825
|
+
this.uniforms.resolution.value.copy( value );
|
|
98826
|
+
|
|
98827
|
+
}
|
|
98828
|
+
|
|
98829
|
+
}
|
|
98830
|
+
|
|
98831
|
+
} );
|
|
98832
|
+
|
|
98833
|
+
this.setValues( parameters );
|
|
98834
|
+
|
|
98835
|
+
};
|
|
98836
|
+
|
|
98837
|
+
LineMaterial.prototype = Object.create( ShaderMaterial.prototype );
|
|
98838
|
+
LineMaterial.prototype.constructor = LineMaterial;
|
|
98839
|
+
|
|
98840
|
+
LineMaterial.prototype.isLineMaterial = true;var LineSegments2 = function ( geometry, material ) {
|
|
98841
|
+
|
|
98842
|
+
if ( geometry === undefined ) geometry = new LineSegmentsGeometry();
|
|
98843
|
+
if ( material === undefined ) material = new LineMaterial( { color: Math.random() * 0xffffff } );
|
|
98844
|
+
|
|
98845
|
+
Mesh.call( this, geometry, material );
|
|
98846
|
+
|
|
98847
|
+
this.type = 'LineSegments2';
|
|
98848
|
+
|
|
98849
|
+
};
|
|
98850
|
+
|
|
98851
|
+
LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), {
|
|
98852
|
+
|
|
98853
|
+
constructor: LineSegments2,
|
|
98854
|
+
|
|
98855
|
+
isLineSegments2: true,
|
|
98856
|
+
|
|
98857
|
+
computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry...
|
|
98858
|
+
|
|
98859
|
+
var start = new Vector3$1();
|
|
98860
|
+
var end = new Vector3$1();
|
|
98861
|
+
|
|
98862
|
+
return function computeLineDistances() {
|
|
98863
|
+
|
|
98864
|
+
var geometry = this.geometry;
|
|
98865
|
+
|
|
98866
|
+
var instanceStart = geometry.attributes.instanceStart;
|
|
98867
|
+
var instanceEnd = geometry.attributes.instanceEnd;
|
|
98868
|
+
var lineDistances = new Float32Array( 2 * instanceStart.data.count );
|
|
98869
|
+
|
|
98870
|
+
for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) {
|
|
98871
|
+
|
|
98872
|
+
start.fromBufferAttribute( instanceStart, i );
|
|
98873
|
+
end.fromBufferAttribute( instanceEnd, i );
|
|
98874
|
+
|
|
98875
|
+
lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
|
|
98876
|
+
lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end );
|
|
98877
|
+
|
|
98878
|
+
}
|
|
98879
|
+
|
|
98880
|
+
var instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
|
|
98881
|
+
|
|
98882
|
+
geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
|
|
98883
|
+
geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
|
|
98884
|
+
|
|
98885
|
+
return this;
|
|
98886
|
+
|
|
98887
|
+
};
|
|
98888
|
+
|
|
98889
|
+
}() ),
|
|
98890
|
+
|
|
98891
|
+
raycast: ( function () {
|
|
98892
|
+
|
|
98893
|
+
var start = new Vector4();
|
|
98894
|
+
var end = new Vector4();
|
|
98895
|
+
|
|
98896
|
+
var ssOrigin = new Vector4();
|
|
98897
|
+
var ssOrigin3 = new Vector3$1();
|
|
98898
|
+
var mvMatrix = new Matrix4();
|
|
98899
|
+
var line = new Line3();
|
|
98900
|
+
var closestPoint = new Vector3$1();
|
|
98901
|
+
|
|
98902
|
+
return function raycast( raycaster, intersects ) {
|
|
98903
|
+
|
|
98904
|
+
if ( raycaster.camera === null ) {
|
|
98905
|
+
|
|
98906
|
+
console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.' );
|
|
98907
|
+
|
|
98908
|
+
}
|
|
98909
|
+
|
|
98910
|
+
var threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
|
|
98911
|
+
|
|
98912
|
+
var ray = raycaster.ray;
|
|
98913
|
+
var camera = raycaster.camera;
|
|
98914
|
+
var projectionMatrix = camera.projectionMatrix;
|
|
98915
|
+
|
|
98916
|
+
var geometry = this.geometry;
|
|
98917
|
+
var material = this.material;
|
|
98918
|
+
var resolution = material.resolution;
|
|
98919
|
+
var lineWidth = material.linewidth + threshold;
|
|
98920
|
+
|
|
98921
|
+
var instanceStart = geometry.attributes.instanceStart;
|
|
98922
|
+
var instanceEnd = geometry.attributes.instanceEnd;
|
|
98923
|
+
|
|
98924
|
+
// camera forward is negative
|
|
98925
|
+
var near = - camera.near;
|
|
98926
|
+
|
|
98927
|
+
// pick a point 1 unit out along the ray to avoid the ray origin
|
|
98928
|
+
// sitting at the camera origin which will cause "w" to be 0 when
|
|
98929
|
+
// applying the projection matrix.
|
|
98930
|
+
ray.at( 1, ssOrigin );
|
|
98931
|
+
|
|
98932
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
98933
|
+
ssOrigin.w = 1;
|
|
98934
|
+
ssOrigin.applyMatrix4( camera.matrixWorldInverse );
|
|
98935
|
+
ssOrigin.applyMatrix4( projectionMatrix );
|
|
98936
|
+
ssOrigin.multiplyScalar( 1 / ssOrigin.w );
|
|
98937
|
+
|
|
98938
|
+
// screen space
|
|
98939
|
+
ssOrigin.x *= resolution.x / 2;
|
|
98940
|
+
ssOrigin.y *= resolution.y / 2;
|
|
98941
|
+
ssOrigin.z = 0;
|
|
98942
|
+
|
|
98943
|
+
ssOrigin3.copy( ssOrigin );
|
|
98944
|
+
|
|
98945
|
+
var matrixWorld = this.matrixWorld;
|
|
98946
|
+
mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
|
|
98947
|
+
|
|
98948
|
+
for ( var i = 0, l = instanceStart.count; i < l; i ++ ) {
|
|
98949
|
+
|
|
98950
|
+
start.fromBufferAttribute( instanceStart, i );
|
|
98951
|
+
end.fromBufferAttribute( instanceEnd, i );
|
|
98952
|
+
|
|
98953
|
+
start.w = 1;
|
|
98954
|
+
end.w = 1;
|
|
98955
|
+
|
|
98956
|
+
// camera space
|
|
98957
|
+
start.applyMatrix4( mvMatrix );
|
|
98958
|
+
end.applyMatrix4( mvMatrix );
|
|
98959
|
+
|
|
98960
|
+
// skip the segment if it's entirely behind the camera
|
|
98961
|
+
var isBehindCameraNear = start.z > near && end.z > near;
|
|
98962
|
+
if ( isBehindCameraNear ) {
|
|
98963
|
+
|
|
98964
|
+
continue;
|
|
98965
|
+
|
|
98966
|
+
}
|
|
98967
|
+
|
|
98968
|
+
// trim the segment if it extends behind camera near
|
|
98969
|
+
if ( start.z > near ) {
|
|
98970
|
+
|
|
98971
|
+
const deltaDist = start.z - end.z;
|
|
98972
|
+
const t = ( start.z - near ) / deltaDist;
|
|
98973
|
+
start.lerp( end, t );
|
|
98974
|
+
|
|
98975
|
+
} else if ( end.z > near ) {
|
|
98976
|
+
|
|
98977
|
+
const deltaDist = end.z - start.z;
|
|
98978
|
+
const t = ( end.z - near ) / deltaDist;
|
|
98979
|
+
end.lerp( start, t );
|
|
98980
|
+
|
|
98981
|
+
}
|
|
98982
|
+
|
|
98983
|
+
// clip space
|
|
98984
|
+
start.applyMatrix4( projectionMatrix );
|
|
98985
|
+
end.applyMatrix4( projectionMatrix );
|
|
98986
|
+
|
|
98987
|
+
// ndc space [ - 1.0, 1.0 ]
|
|
98988
|
+
start.multiplyScalar( 1 / start.w );
|
|
98989
|
+
end.multiplyScalar( 1 / end.w );
|
|
98990
|
+
|
|
98991
|
+
// screen space
|
|
98992
|
+
start.x *= resolution.x / 2;
|
|
98993
|
+
start.y *= resolution.y / 2;
|
|
98994
|
+
|
|
98995
|
+
end.x *= resolution.x / 2;
|
|
98996
|
+
end.y *= resolution.y / 2;
|
|
98997
|
+
|
|
98998
|
+
// create 2d segment
|
|
98999
|
+
line.start.copy( start );
|
|
99000
|
+
line.start.z = 0;
|
|
99001
|
+
|
|
99002
|
+
line.end.copy( end );
|
|
99003
|
+
line.end.z = 0;
|
|
99004
|
+
|
|
99005
|
+
// get closest point on ray to segment
|
|
99006
|
+
var param = line.closestPointToPointParameter( ssOrigin3, true );
|
|
99007
|
+
line.at( param, closestPoint );
|
|
99008
|
+
|
|
99009
|
+
// check if the intersection point is within clip space
|
|
99010
|
+
var zPos = MathUtils.lerp( start.z, end.z, param );
|
|
99011
|
+
var isInClipSpace = zPos >= - 1 && zPos <= 1;
|
|
99012
|
+
|
|
99013
|
+
var isInside = ssOrigin3.distanceTo( closestPoint ) < lineWidth * 0.5;
|
|
99014
|
+
|
|
99015
|
+
if ( isInClipSpace && isInside ) {
|
|
99016
|
+
|
|
99017
|
+
line.start.fromBufferAttribute( instanceStart, i );
|
|
99018
|
+
line.end.fromBufferAttribute( instanceEnd, i );
|
|
99019
|
+
|
|
99020
|
+
line.start.applyMatrix4( matrixWorld );
|
|
99021
|
+
line.end.applyMatrix4( matrixWorld );
|
|
99022
|
+
|
|
99023
|
+
var pointOnLine = new Vector3$1();
|
|
99024
|
+
var point = new Vector3$1();
|
|
99025
|
+
|
|
99026
|
+
ray.distanceSqToSegment( line.start, line.end, point, pointOnLine );
|
|
99027
|
+
|
|
99028
|
+
intersects.push( {
|
|
99029
|
+
|
|
99030
|
+
point: point,
|
|
99031
|
+
pointOnLine: pointOnLine,
|
|
99032
|
+
distance: ray.origin.distanceTo( point ),
|
|
99033
|
+
|
|
99034
|
+
object: this,
|
|
99035
|
+
face: null,
|
|
99036
|
+
faceIndex: i,
|
|
99037
|
+
uv: null,
|
|
99038
|
+
uv2: null,
|
|
99039
|
+
|
|
99040
|
+
} );
|
|
99041
|
+
|
|
99042
|
+
}
|
|
99043
|
+
|
|
99044
|
+
}
|
|
99045
|
+
|
|
99046
|
+
};
|
|
99047
|
+
|
|
99048
|
+
}() )
|
|
99049
|
+
|
|
99050
|
+
} );const BLOB_TYPE = "application/javascript";
|
|
98066
99051
|
const createBlob = task => new Blob(["(", task.toString(), ")()"], {
|
|
98067
99052
|
type: BLOB_TYPE
|
|
98068
99053
|
});
|
|
@@ -98155,22 +99140,34 @@ const DEFAULT_HITBOX_OPTIONS = {
|
|
|
98155
99140
|
shadowsEnabled: false
|
|
98156
99141
|
};
|
|
98157
99142
|
const getBoxHitbox = element => {
|
|
98158
|
-
const
|
|
98159
|
-
|
|
98160
|
-
|
|
98161
|
-
|
|
98162
|
-
|
|
98163
|
-
|
|
98164
|
-
}
|
|
98165
|
-
|
|
98166
|
-
|
|
98167
|
-
|
|
99143
|
+
const opts = element.getPhysicsOptions() || {};
|
|
99144
|
+
let w, h, l;
|
|
99145
|
+
if (opts.colliderWidth != null || opts.colliderHeight != null || opts.colliderLength != null) {
|
|
99146
|
+
w = (opts.colliderWidth ?? 1) + HIT_BOX_INCREASE;
|
|
99147
|
+
h = (opts.colliderHeight ?? 1) + HIT_BOX_INCREASE;
|
|
99148
|
+
l = (opts.colliderLength ?? 1) + HIT_BOX_INCREASE;
|
|
99149
|
+
} else {
|
|
99150
|
+
const size = getWorldBoundingBoxSize(element.getBody());
|
|
99151
|
+
if (size) {
|
|
99152
|
+
w = size.width + HIT_BOX_INCREASE;
|
|
99153
|
+
h = size.height + HIT_BOX_INCREASE;
|
|
99154
|
+
l = size.length + HIT_BOX_INCREASE;
|
|
99155
|
+
} else {
|
|
99156
|
+
const fallback = new Vector3$1();
|
|
99157
|
+
element.boundingBox.getSize(fallback);
|
|
99158
|
+
w = fallback.x + HIT_BOX_INCREASE;
|
|
99159
|
+
h = fallback.y + HIT_BOX_INCREASE;
|
|
99160
|
+
l = fallback.z + HIT_BOX_INCREASE;
|
|
99161
|
+
}
|
|
99162
|
+
}
|
|
99163
|
+
const box = new Box(w, h, l, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS);
|
|
98168
99164
|
box.setWireframe(true);
|
|
98169
99165
|
box.setWireframeLineWidth(2);
|
|
98170
99166
|
return box;
|
|
98171
99167
|
};
|
|
98172
99168
|
const getSphereHitbox = element => {
|
|
98173
|
-
const
|
|
99169
|
+
const opts = element.getPhysicsOptions() || {};
|
|
99170
|
+
const radius = opts.colliderRadius ?? getWorldBoundingSphereRadius(element.getBody()) ?? element.boundingSphere.radius;
|
|
98174
99171
|
const sphere = new Sphere(radius, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS);
|
|
98175
99172
|
sphere.setWireframe(true);
|
|
98176
99173
|
sphere.setWireframeLineWidth(2);
|
|
@@ -100314,4 +101311,4 @@ var Shaders$1 = new Shaders();let Shader = /*#__PURE__*/_createClass(function Sh
|
|
|
100314
101311
|
...light_contants,
|
|
100315
101312
|
...material_constants,
|
|
100316
101313
|
...controls_contants
|
|
100317
|
-
};export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,CONTROL_EVENTS,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,Explosion,Exporter,FEATURES,Features$1 as Features,Fire,Fountain,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Importer,Input$1 as Input,Label,LabelComponent,Level,Lights$1 as Lights,Line,MirrorElement as Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Rain,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Snow,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,THREEJS_CONTROL_EVENTS,Trail,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,map$1 as map,math,object,physicsUtils,index$1 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$2 as xstate};
|
|
101314
|
+
};export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,CONTROL_EVENTS,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,Explosion,Exporter,FEATURES,Features$1 as Features,Fire,Fountain,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Importer,Input$1 as Input,Label,LabelComponent,Level,Lights$1 as Lights,Line,LineMaterial,LineSegments2,LineSegmentsGeometry,MirrorElement as Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Rain,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Snow,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,THREEJS_CONTROL_EVENTS,Trail,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,map$1 as map,math,object,physicsUtils,index$1 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$2 as xstate};
|