mage-engine 3.16.6 → 3.16.7
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 +500 -25
- package/package.json +1 -1
package/dist/mage.js
CHANGED
|
@@ -54628,7 +54628,7 @@ var EFFECTS = {
|
|
|
54628
54628
|
HUE_SATURATION: 'HUESATURATIONEFFECT',
|
|
54629
54629
|
BLOOM: 'BLOOM',
|
|
54630
54630
|
DEPTH_OF_FIELD: 'DOF',
|
|
54631
|
-
|
|
54631
|
+
SELECTIVE_OUTLINE: 'SELECTIVEOUTLINE',
|
|
54632
54632
|
OUTLINE: 'OUTLINE',
|
|
54633
54633
|
GLITCH: 'GLITCH',
|
|
54634
54634
|
PIXEL: 'PIXEL'
|
|
@@ -56231,7 +56231,7 @@ function applyMiddleware() {
|
|
|
56231
56231
|
|
|
56232
56232
|
var thunk = createThunkMiddleware();
|
|
56233
56233
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
56234
|
-
var version = "3.16.
|
|
56234
|
+
var version = "3.16.7";
|
|
56235
56235
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
56236
56236
|
var main = "dist/mage.js";
|
|
56237
56237
|
var author = {
|
|
@@ -57602,6 +57602,9 @@ var getProportion = function getProportion(max1, b, max2) {
|
|
|
57602
57602
|
var clamp = function clamp(value, min, max) {
|
|
57603
57603
|
return value < min ? min : value > max ? max : value;
|
|
57604
57604
|
};
|
|
57605
|
+
var isWithin = function isWithin(value, min, max) {
|
|
57606
|
+
return value >= min && value < max;
|
|
57607
|
+
};
|
|
57605
57608
|
var randomIntFromInterval = function randomIntFromInterval(min, max) {
|
|
57606
57609
|
// min and max included
|
|
57607
57610
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
@@ -57715,7 +57718,7 @@ var smoothDampAngle = function smoothDampAngle(current, target, currentVelocity,
|
|
|
57715
57718
|
var dt = arguments.length > 5 ? arguments[5] : undefined;
|
|
57716
57719
|
target = current + deltaAngle(current, target);
|
|
57717
57720
|
return smoothDamp(current, target, currentVelocity, smoothTime, maxSpeed, dt);
|
|
57718
|
-
};var math=/*#__PURE__*/Object.freeze({__proto__:null,PI: PI,PI_2: PI_2,pickRandom: pickRandom,degToRad: degToRad,getProportion: getProportion,clamp: clamp,randomIntFromInterval: randomIntFromInterval,getDistance: getDistance,findPointBetweenAtDistance: findPointBetweenAtDistance,lerpVectors: lerpVectors,lerp: lerp,scaleVector: scaleVector,getSphereVolume: getSphereVolume,repeat: repeat,deltaAngle: deltaAngle,smoothDamp: smoothDamp,smoothDampAngle: smoothDampAngle});var LIBRARY_NAME = 'ammo.js';
|
|
57721
|
+
};var math=/*#__PURE__*/Object.freeze({__proto__:null,PI: PI,PI_2: PI_2,pickRandom: pickRandom,degToRad: degToRad,getProportion: getProportion,clamp: clamp,isWithin: isWithin,randomIntFromInterval: randomIntFromInterval,getDistance: getDistance,findPointBetweenAtDistance: findPointBetweenAtDistance,lerpVectors: lerpVectors,lerp: lerp,scaleVector: scaleVector,getSphereVolume: getSphereVolume,repeat: repeat,deltaAngle: deltaAngle,smoothDamp: smoothDamp,smoothDampAngle: smoothDampAngle});var LIBRARY_NAME = 'ammo.js';
|
|
57719
57722
|
var TYPES = {
|
|
57720
57723
|
BOX: 'BOX',
|
|
57721
57724
|
SPHERE: 'SPHERE',
|
|
@@ -60450,7 +60453,7 @@ var Entity = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
60450
60453
|
var _add = function _add(toAdd) {
|
|
60451
60454
|
_this2.children.push(toAdd);
|
|
60452
60455
|
|
|
60453
|
-
_this2.
|
|
60456
|
+
_this2.getBody().add(toAdd.getBody());
|
|
60454
60457
|
};
|
|
60455
60458
|
|
|
60456
60459
|
if (Array.isArray(element)) {
|
|
@@ -75330,30 +75333,42 @@ var LightLoader$1 = new LightLoader();var Pass = /*#__PURE__*/function () {
|
|
|
75330
75333
|
return Pass;
|
|
75331
75334
|
}(); // Helper for passes that need to fill the viewport with a single quad.
|
|
75332
75335
|
|
|
75333
|
-
|
|
75334
|
-
var camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
75335
|
-
var geometry = new PlaneGeometry(2, 2);
|
|
75336
|
+
var _camera$1 = new OrthographicCamera(-1, 1, 1, -1, 0, 1); // https://github.com/mrdoob/three.js/pull/21358
|
|
75336
75337
|
|
|
75337
|
-
var FullScreenQuad = function FullScreenQuad(material) {
|
|
75338
|
-
this._mesh = new Mesh(geometry, material);
|
|
75339
|
-
};
|
|
75340
75338
|
|
|
75341
|
-
|
|
75339
|
+
var _geometry$1 = new BufferGeometry();
|
|
75340
|
+
|
|
75341
|
+
_geometry$1.setAttribute('position', new Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3));
|
|
75342
|
+
|
|
75343
|
+
_geometry$1.setAttribute('uv', new Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
|
|
75344
|
+
|
|
75345
|
+
var FullScreenQuad = /*#__PURE__*/function () {
|
|
75346
|
+
function FullScreenQuad(material) {
|
|
75347
|
+
_classCallCheck(this, FullScreenQuad);
|
|
75348
|
+
|
|
75349
|
+
this._mesh = new Mesh(_geometry$1, material);
|
|
75350
|
+
}
|
|
75351
|
+
|
|
75352
|
+
_createClass(FullScreenQuad, [{
|
|
75353
|
+
key: "dispose",
|
|
75354
|
+
value: function dispose() {
|
|
75355
|
+
this._mesh.geometry.dispose();
|
|
75356
|
+
}
|
|
75357
|
+
}, {
|
|
75358
|
+
key: "render",
|
|
75359
|
+
value: function render(renderer) {
|
|
75360
|
+
renderer.render(this._mesh, _camera$1);
|
|
75361
|
+
}
|
|
75362
|
+
}, {
|
|
75363
|
+
key: "material",
|
|
75342
75364
|
get: function get() {
|
|
75343
75365
|
return this._mesh.material;
|
|
75344
75366
|
},
|
|
75345
75367
|
set: function set(value) {
|
|
75346
75368
|
this._mesh.material = value;
|
|
75347
75369
|
}
|
|
75348
|
-
});
|
|
75349
|
-
|
|
75350
|
-
dispose: function dispose() {
|
|
75351
|
-
this._mesh.geometry.dispose();
|
|
75352
|
-
},
|
|
75353
|
-
render: function render(renderer) {
|
|
75354
|
-
renderer.render(this._mesh, camera);
|
|
75355
|
-
}
|
|
75356
|
-
});
|
|
75370
|
+
}]);
|
|
75371
|
+
|
|
75357
75372
|
return FullScreenQuad;
|
|
75358
75373
|
}();var ShaderPass = /*#__PURE__*/function (_Pass) {
|
|
75359
75374
|
_inherits(ShaderPass, _Pass);
|
|
@@ -75381,7 +75396,7 @@ Pass.FullScreenQuad = function () {
|
|
|
75381
75396
|
});
|
|
75382
75397
|
}
|
|
75383
75398
|
|
|
75384
|
-
_this.fsQuad = new
|
|
75399
|
+
_this.fsQuad = new FullScreenQuad(_this.material);
|
|
75385
75400
|
return _this;
|
|
75386
75401
|
}
|
|
75387
75402
|
|
|
@@ -75928,7 +75943,7 @@ var BloomPass = /*#__PURE__*/function (_Pass) {
|
|
|
75928
75943
|
}
|
|
75929
75944
|
});
|
|
75930
75945
|
_this.needsSwap = false;
|
|
75931
|
-
_this.fsQuad = new
|
|
75946
|
+
_this.fsQuad = new FullScreenQuad(null);
|
|
75932
75947
|
_this.renderToScreen = renderToScreen;
|
|
75933
75948
|
return _this;
|
|
75934
75949
|
}
|
|
@@ -76057,7 +76072,7 @@ var BokehShader = {
|
|
|
76057
76072
|
});
|
|
76058
76073
|
_this.uniforms = bokehUniforms;
|
|
76059
76074
|
_this.needsSwap = false;
|
|
76060
|
-
_this.fsQuad = new
|
|
76075
|
+
_this.fsQuad = new FullScreenQuad(_this.materialBokeh);
|
|
76061
76076
|
_this._oldClearColor = new Color();
|
|
76062
76077
|
_this.renderToScreen = renderToScreen;
|
|
76063
76078
|
return _this;
|
|
@@ -76136,7 +76151,464 @@ var BokehShader = {
|
|
|
76136
76151
|
}
|
|
76137
76152
|
|
|
76138
76153
|
return DepthOfField;
|
|
76139
|
-
}(BokehPass)
|
|
76154
|
+
}(BokehPass);var MAX_EDGE_THICKNESS = 4;
|
|
76155
|
+
var MAX_EDGE_GLOW = 4;
|
|
76156
|
+
var BlurDirectionX = new Vector2(1.0, 0.0);
|
|
76157
|
+
var BlurDirectionY = new Vector2(0.0, 1.0);
|
|
76158
|
+
|
|
76159
|
+
var replaceDepthToViewZ = function replaceDepthToViewZ(string, camera) {
|
|
76160
|
+
var type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
|
|
76161
|
+
return string.replace(/DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ');
|
|
76162
|
+
};
|
|
76163
|
+
|
|
76164
|
+
var SelectiveOutline = /*#__PURE__*/function (_Pass) {
|
|
76165
|
+
_inherits(SelectiveOutline, _Pass);
|
|
76166
|
+
|
|
76167
|
+
var _super = _createSuper(SelectiveOutline);
|
|
76168
|
+
|
|
76169
|
+
function SelectiveOutline(_ref) {
|
|
76170
|
+
var _this;
|
|
76171
|
+
|
|
76172
|
+
var _ref$resolution = _ref.resolution,
|
|
76173
|
+
resolution = _ref$resolution === void 0 ? {} : _ref$resolution,
|
|
76174
|
+
selectedObjects = _ref.selectedObjects,
|
|
76175
|
+
_ref$visibleEdgeColor = _ref.visibleEdgeColor,
|
|
76176
|
+
visibleEdgeColor = _ref$visibleEdgeColor === void 0 ? PALETTES.BASE.WHITE : _ref$visibleEdgeColor,
|
|
76177
|
+
_ref$hiddenEdgeColor = _ref.hiddenEdgeColor,
|
|
76178
|
+
hiddenEdgeColor = _ref$hiddenEdgeColor === void 0 ? PALETTES.BASE.BLACK : _ref$hiddenEdgeColor;
|
|
76179
|
+
|
|
76180
|
+
_classCallCheck(this, SelectiveOutline);
|
|
76181
|
+
|
|
76182
|
+
_this = _super.call(this);
|
|
76183
|
+
|
|
76184
|
+
var _config$screen = Config$1.screen(),
|
|
76185
|
+
height = _config$screen.h,
|
|
76186
|
+
width = _config$screen.w;
|
|
76187
|
+
|
|
76188
|
+
var _resolution$x = resolution.x,
|
|
76189
|
+
resolutionX = _resolution$x === void 0 ? width : _resolution$x,
|
|
76190
|
+
_resolution$y = resolution.y,
|
|
76191
|
+
resolutionY = _resolution$y === void 0 ? height : _resolution$y;
|
|
76192
|
+
_this.renderScene = Scene$2.getScene();
|
|
76193
|
+
_this.renderCamera = Scene$2.getCameraBody();
|
|
76194
|
+
_this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
|
|
76195
|
+
_this.visibleEdgeColor = visibleEdgeColor;
|
|
76196
|
+
_this.hiddenEdgeColor = hiddenEdgeColor;
|
|
76197
|
+
_this.edgeGlow = 0.0;
|
|
76198
|
+
_this.usePatternTexture = false;
|
|
76199
|
+
_this.edgeThickness = 1.0;
|
|
76200
|
+
_this.edgeStrength = 3.0;
|
|
76201
|
+
_this.downSampleRatio = 2;
|
|
76202
|
+
_this.pulsePeriod = 0;
|
|
76203
|
+
_this._visibilityCache = new Map();
|
|
76204
|
+
_this.resolution = new Vector2(resolutionX, resolutionY);
|
|
76205
|
+
var pars = {
|
|
76206
|
+
minFilter: LinearFilter,
|
|
76207
|
+
magFilter: LinearFilter,
|
|
76208
|
+
format: RGBAFormat
|
|
76209
|
+
};
|
|
76210
|
+
var resx = Math.round(_this.resolutionX / _this.downSampleRatio);
|
|
76211
|
+
var resy = Math.round(_this.resolutionY / _this.downSampleRatio);
|
|
76212
|
+
_this.renderTargetMaskBuffer = new WebGLRenderTarget(_this.resolutionX, _this.resolutionY, pars);
|
|
76213
|
+
_this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
|
|
76214
|
+
_this.renderTargetMaskBuffer.texture.generateMipmaps = false;
|
|
76215
|
+
_this.depthMaterial = new MeshDepthMaterial();
|
|
76216
|
+
_this.depthMaterial.side = DoubleSide;
|
|
76217
|
+
_this.depthMaterial.depthPacking = RGBADepthPacking;
|
|
76218
|
+
_this.depthMaterial.blending = NoBlending;
|
|
76219
|
+
_this.prepareMaskMaterial = _this.getPrepareMaskMaterial();
|
|
76220
|
+
_this.prepareMaskMaterial.side = DoubleSide;
|
|
76221
|
+
_this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ(_this.prepareMaskMaterial.fragmentShader, _this.renderCamera);
|
|
76222
|
+
_this.renderTargetDepthBuffer = new WebGLRenderTarget(_this.resolutionX, _this.resolutionY, pars);
|
|
76223
|
+
_this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
|
|
76224
|
+
_this.renderTargetDepthBuffer.texture.generateMipmaps = false;
|
|
76225
|
+
_this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget(resx, resy, pars);
|
|
76226
|
+
_this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
|
|
76227
|
+
_this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
|
|
76228
|
+
_this.renderTargetBlurBuffer1 = new WebGLRenderTarget(resx, resy, pars);
|
|
76229
|
+
_this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
|
|
76230
|
+
_this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
|
|
76231
|
+
_this.renderTargetBlurBuffer2 = new WebGLRenderTarget(Math.round(resx / 2), Math.round(resy / 2), pars);
|
|
76232
|
+
_this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
|
|
76233
|
+
_this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
|
|
76234
|
+
_this.edgeDetectionMaterial = _this.getEdgeDetectionMaterial();
|
|
76235
|
+
_this.renderTargetEdgeBuffer1 = new WebGLRenderTarget(resx, resy, pars);
|
|
76236
|
+
_this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
|
|
76237
|
+
_this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
|
|
76238
|
+
_this.renderTargetEdgeBuffer2 = new WebGLRenderTarget(Math.round(resx / 2), Math.round(resy / 2), pars);
|
|
76239
|
+
_this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
|
|
76240
|
+
_this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
|
|
76241
|
+
_this.separableBlurMaterial1 = _this.getSeperableBlurMaterial(MAX_EDGE_THICKNESS);
|
|
76242
|
+
|
|
76243
|
+
_this.separableBlurMaterial1.uniforms['texSize'].value.set(resx, resy);
|
|
76244
|
+
|
|
76245
|
+
_this.separableBlurMaterial1.uniforms['kernelRadius'].value = 1;
|
|
76246
|
+
_this.separableBlurMaterial2 = _this.getSeperableBlurMaterial(MAX_EDGE_GLOW);
|
|
76247
|
+
|
|
76248
|
+
_this.separableBlurMaterial2.uniforms['texSize'].value.set(Math.round(resx / 2), Math.round(resy / 2));
|
|
76249
|
+
|
|
76250
|
+
_this.separableBlurMaterial2.uniforms['kernelRadius'].value = MAX_EDGE_GLOW; // Overlay material
|
|
76251
|
+
|
|
76252
|
+
_this.overlayMaterial = _this.getOverlayMaterial(); // copy material
|
|
76253
|
+
|
|
76254
|
+
if (CopyShader === undefined) console.error('THREE.OutlinePass relies on CopyShader');
|
|
76255
|
+
var copyShader = CopyShader;
|
|
76256
|
+
_this.copyUniforms = UniformsUtils.clone(copyShader.uniforms);
|
|
76257
|
+
_this.copyUniforms['opacity'].value = 1.0;
|
|
76258
|
+
_this.materialCopy = new ShaderMaterial({
|
|
76259
|
+
uniforms: _this.copyUniforms,
|
|
76260
|
+
vertexShader: copyShader.vertexShader,
|
|
76261
|
+
fragmentShader: copyShader.fragmentShader,
|
|
76262
|
+
blending: NoBlending,
|
|
76263
|
+
depthTest: false,
|
|
76264
|
+
depthWrite: false,
|
|
76265
|
+
transparent: true
|
|
76266
|
+
});
|
|
76267
|
+
_this.enabled = true;
|
|
76268
|
+
_this.needsSwap = false;
|
|
76269
|
+
_this._oldClearColor = new Color();
|
|
76270
|
+
_this.oldClearAlpha = 1;
|
|
76271
|
+
_this.fsQuad = new FullScreenQuad(null);
|
|
76272
|
+
_this.tempPulseColor1 = new Color();
|
|
76273
|
+
_this.tempPulseColor2 = new Color();
|
|
76274
|
+
_this.textureMatrix = new Matrix4();
|
|
76275
|
+
return _this;
|
|
76276
|
+
}
|
|
76277
|
+
|
|
76278
|
+
_createClass(SelectiveOutline, [{
|
|
76279
|
+
key: "setSelectedObjects",
|
|
76280
|
+
value: function setSelectedObjects() {
|
|
76281
|
+
var selectedObjects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
76282
|
+
this.selectedObjects = selectedObjects.map(function (o) {
|
|
76283
|
+
return o.getBody();
|
|
76284
|
+
});
|
|
76285
|
+
}
|
|
76286
|
+
}, {
|
|
76287
|
+
key: "dispose",
|
|
76288
|
+
value: function dispose() {
|
|
76289
|
+
this.renderTargetMaskBuffer.dispose();
|
|
76290
|
+
this.renderTargetDepthBuffer.dispose();
|
|
76291
|
+
this.renderTargetMaskDownSampleBuffer.dispose();
|
|
76292
|
+
this.renderTargetBlurBuffer1.dispose();
|
|
76293
|
+
this.renderTargetBlurBuffer2.dispose();
|
|
76294
|
+
this.renderTargetEdgeBuffer1.dispose();
|
|
76295
|
+
this.renderTargetEdgeBuffer2.dispose();
|
|
76296
|
+
}
|
|
76297
|
+
}, {
|
|
76298
|
+
key: "setSize",
|
|
76299
|
+
value: function setSize(width, height) {
|
|
76300
|
+
this.renderTargetMaskBuffer.setSize(width, height);
|
|
76301
|
+
this.renderTargetDepthBuffer.setSize(width, height);
|
|
76302
|
+
var resx = Math.round(width / this.downSampleRatio);
|
|
76303
|
+
var resy = Math.round(height / this.downSampleRatio);
|
|
76304
|
+
this.renderTargetMaskDownSampleBuffer.setSize(resx, resy);
|
|
76305
|
+
this.renderTargetBlurBuffer1.setSize(resx, resy);
|
|
76306
|
+
this.renderTargetEdgeBuffer1.setSize(resx, resy);
|
|
76307
|
+
this.separableBlurMaterial1.uniforms['texSize'].value.set(resx, resy);
|
|
76308
|
+
resx = Math.round(resx / 2);
|
|
76309
|
+
resy = Math.round(resy / 2);
|
|
76310
|
+
this.renderTargetBlurBuffer2.setSize(resx, resy);
|
|
76311
|
+
this.renderTargetEdgeBuffer2.setSize(resx, resy);
|
|
76312
|
+
this.separableBlurMaterial2.uniforms['texSize'].value.set(resx, resy);
|
|
76313
|
+
}
|
|
76314
|
+
}, {
|
|
76315
|
+
key: "changeVisibilityOfSelectedObjects",
|
|
76316
|
+
value: function changeVisibilityOfSelectedObjects(bVisible) {
|
|
76317
|
+
var cache = this._visibilityCache;
|
|
76318
|
+
|
|
76319
|
+
function gatherSelectedMeshesCallBack(object) {
|
|
76320
|
+
if (object.isMesh) {
|
|
76321
|
+
if (bVisible === true) {
|
|
76322
|
+
object.visible = cache.get(object);
|
|
76323
|
+
} else {
|
|
76324
|
+
cache.set(object, object.visible);
|
|
76325
|
+
object.visible = bVisible;
|
|
76326
|
+
}
|
|
76327
|
+
}
|
|
76328
|
+
}
|
|
76329
|
+
|
|
76330
|
+
for (var i = 0; i < this.selectedObjects.length; i++) {
|
|
76331
|
+
var selectedObject = this.selectedObjects[i];
|
|
76332
|
+
selectedObject.traverse(gatherSelectedMeshesCallBack);
|
|
76333
|
+
}
|
|
76334
|
+
}
|
|
76335
|
+
}, {
|
|
76336
|
+
key: "changeVisibilityOfNonSelectedObjects",
|
|
76337
|
+
value: function changeVisibilityOfNonSelectedObjects(bVisible) {
|
|
76338
|
+
var cache = this._visibilityCache;
|
|
76339
|
+
var selectedMeshes = [];
|
|
76340
|
+
|
|
76341
|
+
function gatherSelectedMeshesCallBack(object) {
|
|
76342
|
+
if (object.isMesh) selectedMeshes.push(object);
|
|
76343
|
+
}
|
|
76344
|
+
|
|
76345
|
+
for (var i = 0; i < this.selectedObjects.length; i++) {
|
|
76346
|
+
var selectedObject = this.selectedObjects[i];
|
|
76347
|
+
selectedObject.traverse(gatherSelectedMeshesCallBack);
|
|
76348
|
+
}
|
|
76349
|
+
|
|
76350
|
+
function VisibilityChangeCallBack(object) {
|
|
76351
|
+
if (object.isMesh || object.isSprite) {
|
|
76352
|
+
// only meshes and sprites are supported by OutlinePass
|
|
76353
|
+
var bFound = false;
|
|
76354
|
+
|
|
76355
|
+
for (var _i = 0; _i < selectedMeshes.length; _i++) {
|
|
76356
|
+
var selectedObjectId = selectedMeshes[_i].id;
|
|
76357
|
+
|
|
76358
|
+
if (selectedObjectId === object.id) {
|
|
76359
|
+
bFound = true;
|
|
76360
|
+
break;
|
|
76361
|
+
}
|
|
76362
|
+
}
|
|
76363
|
+
|
|
76364
|
+
if (bFound === false) {
|
|
76365
|
+
var visibility = object.visible;
|
|
76366
|
+
|
|
76367
|
+
if (bVisible === false || cache.get(object) === true) {
|
|
76368
|
+
object.visible = bVisible;
|
|
76369
|
+
}
|
|
76370
|
+
|
|
76371
|
+
cache.set(object, visibility);
|
|
76372
|
+
}
|
|
76373
|
+
} else if (object.isPoints || object.isLine) {
|
|
76374
|
+
// the visibilty of points and lines is always set to false in order to
|
|
76375
|
+
// not affect the outline computation
|
|
76376
|
+
if (bVisible === true) {
|
|
76377
|
+
object.visible = cache.get(object); // restore
|
|
76378
|
+
} else {
|
|
76379
|
+
cache.set(object, object.visible);
|
|
76380
|
+
object.visible = bVisible;
|
|
76381
|
+
}
|
|
76382
|
+
}
|
|
76383
|
+
}
|
|
76384
|
+
|
|
76385
|
+
this.renderScene.traverse(VisibilityChangeCallBack);
|
|
76386
|
+
}
|
|
76387
|
+
}, {
|
|
76388
|
+
key: "updateTextureMatrix",
|
|
76389
|
+
value: function updateTextureMatrix() {
|
|
76390
|
+
this.textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
|
|
76391
|
+
this.textureMatrix.multiply(this.renderCamera.projectionMatrix);
|
|
76392
|
+
this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse);
|
|
76393
|
+
}
|
|
76394
|
+
}, {
|
|
76395
|
+
key: "render",
|
|
76396
|
+
value: function render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
|
|
76397
|
+
if (this.selectedObjects.length > 0) {
|
|
76398
|
+
renderer.getClearColor(this._oldClearColor);
|
|
76399
|
+
this.oldClearAlpha = renderer.getClearAlpha();
|
|
76400
|
+
var oldAutoClear = renderer.autoClear;
|
|
76401
|
+
renderer.autoClear = false;
|
|
76402
|
+
if (maskActive) renderer.state.buffers.stencil.setTest(false);
|
|
76403
|
+
renderer.setClearColor(0xffffff, 1); // Make selected objects invisible
|
|
76404
|
+
|
|
76405
|
+
this.changeVisibilityOfSelectedObjects(false);
|
|
76406
|
+
var currentBackground = this.renderScene.background;
|
|
76407
|
+
this.renderScene.background = null; // 1. Draw Non Selected objects in the depth buffer
|
|
76408
|
+
|
|
76409
|
+
this.renderScene.overrideMaterial = this.depthMaterial;
|
|
76410
|
+
renderer.setRenderTarget(this.renderTargetDepthBuffer);
|
|
76411
|
+
renderer.clear();
|
|
76412
|
+
renderer.render(this.renderScene, this.renderCamera); // Make selected objects visible
|
|
76413
|
+
|
|
76414
|
+
this.changeVisibilityOfSelectedObjects(true);
|
|
76415
|
+
|
|
76416
|
+
this._visibilityCache.clear(); // Update Texture Matrix for Depth compare
|
|
76417
|
+
|
|
76418
|
+
|
|
76419
|
+
this.updateTextureMatrix(); // Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects
|
|
76420
|
+
|
|
76421
|
+
this.changeVisibilityOfNonSelectedObjects(false);
|
|
76422
|
+
this.renderScene.overrideMaterial = this.prepareMaskMaterial;
|
|
76423
|
+
this.prepareMaskMaterial.uniforms['cameraNearFar'].value.set(this.renderCamera.near, this.renderCamera.far);
|
|
76424
|
+
this.prepareMaskMaterial.uniforms['depthTexture'].value = this.renderTargetDepthBuffer.texture;
|
|
76425
|
+
this.prepareMaskMaterial.uniforms['textureMatrix'].value = this.textureMatrix;
|
|
76426
|
+
renderer.setRenderTarget(this.renderTargetMaskBuffer);
|
|
76427
|
+
renderer.clear();
|
|
76428
|
+
renderer.render(this.renderScene, this.renderCamera);
|
|
76429
|
+
this.renderScene.overrideMaterial = null;
|
|
76430
|
+
this.changeVisibilityOfNonSelectedObjects(true);
|
|
76431
|
+
|
|
76432
|
+
this._visibilityCache.clear();
|
|
76433
|
+
|
|
76434
|
+
this.renderScene.background = currentBackground; // 2. Downsample to Half resolution
|
|
76435
|
+
|
|
76436
|
+
this.fsQuad.material = this.materialCopy;
|
|
76437
|
+
this.copyUniforms['tDiffuse'].value = this.renderTargetMaskBuffer.texture;
|
|
76438
|
+
renderer.setRenderTarget(this.renderTargetMaskDownSampleBuffer);
|
|
76439
|
+
renderer.clear();
|
|
76440
|
+
this.fsQuad.render(renderer);
|
|
76441
|
+
this.tempPulseColor1.copy(this.visibleEdgeColor);
|
|
76442
|
+
this.tempPulseColor2.copy(this.hiddenEdgeColor);
|
|
76443
|
+
|
|
76444
|
+
if (this.pulsePeriod > 0) {
|
|
76445
|
+
var scalar = (1 + 0.25) / 2 + Math.cos(performance.now() * 0.01 / this.pulsePeriod) * (1.0 - 0.25) / 2;
|
|
76446
|
+
this.tempPulseColor1.multiplyScalar(scalar);
|
|
76447
|
+
this.tempPulseColor2.multiplyScalar(scalar);
|
|
76448
|
+
} // 3. Apply Edge Detection Pass
|
|
76449
|
+
|
|
76450
|
+
|
|
76451
|
+
this.fsQuad.material = this.edgeDetectionMaterial;
|
|
76452
|
+
this.edgeDetectionMaterial.uniforms['maskTexture'].value = this.renderTargetMaskDownSampleBuffer.texture;
|
|
76453
|
+
this.edgeDetectionMaterial.uniforms['texSize'].value.set(this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height);
|
|
76454
|
+
this.edgeDetectionMaterial.uniforms['visibleEdgeColor'].value = this.tempPulseColor1;
|
|
76455
|
+
this.edgeDetectionMaterial.uniforms['hiddenEdgeColor'].value = this.tempPulseColor2;
|
|
76456
|
+
renderer.setRenderTarget(this.renderTargetEdgeBuffer1);
|
|
76457
|
+
renderer.clear();
|
|
76458
|
+
this.fsQuad.render(renderer); // 4. Apply Blur on Half res
|
|
76459
|
+
|
|
76460
|
+
this.fsQuad.material = this.separableBlurMaterial1;
|
|
76461
|
+
this.separableBlurMaterial1.uniforms['colorTexture'].value = this.renderTargetEdgeBuffer1.texture;
|
|
76462
|
+
this.separableBlurMaterial1.uniforms['direction'].value = BlurDirectionX;
|
|
76463
|
+
this.separableBlurMaterial1.uniforms['kernelRadius'].value = this.edgeThickness;
|
|
76464
|
+
renderer.setRenderTarget(this.renderTargetBlurBuffer1);
|
|
76465
|
+
renderer.clear();
|
|
76466
|
+
this.fsQuad.render(renderer);
|
|
76467
|
+
this.separableBlurMaterial1.uniforms['colorTexture'].value = this.renderTargetBlurBuffer1.texture;
|
|
76468
|
+
this.separableBlurMaterial1.uniforms['direction'].value = BlurDirectionY;
|
|
76469
|
+
renderer.setRenderTarget(this.renderTargetEdgeBuffer1);
|
|
76470
|
+
renderer.clear();
|
|
76471
|
+
this.fsQuad.render(renderer); // Apply Blur on quarter res
|
|
76472
|
+
|
|
76473
|
+
this.fsQuad.material = this.separableBlurMaterial2;
|
|
76474
|
+
this.separableBlurMaterial2.uniforms['colorTexture'].value = this.renderTargetEdgeBuffer1.texture;
|
|
76475
|
+
this.separableBlurMaterial2.uniforms['direction'].value = BlurDirectionX;
|
|
76476
|
+
renderer.setRenderTarget(this.renderTargetBlurBuffer2);
|
|
76477
|
+
renderer.clear();
|
|
76478
|
+
this.fsQuad.render(renderer);
|
|
76479
|
+
this.separableBlurMaterial2.uniforms['colorTexture'].value = this.renderTargetBlurBuffer2.texture;
|
|
76480
|
+
this.separableBlurMaterial2.uniforms['direction'].value = BlurDirectionY;
|
|
76481
|
+
renderer.setRenderTarget(this.renderTargetEdgeBuffer2);
|
|
76482
|
+
renderer.clear();
|
|
76483
|
+
this.fsQuad.render(renderer); // Blend it additively over the input texture
|
|
76484
|
+
|
|
76485
|
+
this.fsQuad.material = this.overlayMaterial;
|
|
76486
|
+
this.overlayMaterial.uniforms['maskTexture'].value = this.renderTargetMaskBuffer.texture;
|
|
76487
|
+
this.overlayMaterial.uniforms['edgeTexture1'].value = this.renderTargetEdgeBuffer1.texture;
|
|
76488
|
+
this.overlayMaterial.uniforms['edgeTexture2'].value = this.renderTargetEdgeBuffer2.texture;
|
|
76489
|
+
this.overlayMaterial.uniforms['patternTexture'].value = this.patternTexture;
|
|
76490
|
+
this.overlayMaterial.uniforms['edgeStrength'].value = this.edgeStrength;
|
|
76491
|
+
this.overlayMaterial.uniforms['edgeGlow'].value = this.edgeGlow;
|
|
76492
|
+
this.overlayMaterial.uniforms['usePatternTexture'].value = this.usePatternTexture;
|
|
76493
|
+
if (maskActive) renderer.state.buffers.stencil.setTest(true);
|
|
76494
|
+
renderer.setRenderTarget(readBuffer);
|
|
76495
|
+
this.fsQuad.render(renderer);
|
|
76496
|
+
renderer.setClearColor(this._oldClearColor, this.oldClearAlpha);
|
|
76497
|
+
renderer.autoClear = oldAutoClear;
|
|
76498
|
+
}
|
|
76499
|
+
|
|
76500
|
+
if (this.renderToScreen) {
|
|
76501
|
+
this.fsQuad.material = this.materialCopy;
|
|
76502
|
+
this.copyUniforms['tDiffuse'].value = readBuffer.texture;
|
|
76503
|
+
renderer.setRenderTarget(null);
|
|
76504
|
+
this.fsQuad.render(renderer);
|
|
76505
|
+
}
|
|
76506
|
+
}
|
|
76507
|
+
}, {
|
|
76508
|
+
key: "getPrepareMaskMaterial",
|
|
76509
|
+
value: function getPrepareMaskMaterial() {
|
|
76510
|
+
return new ShaderMaterial({
|
|
76511
|
+
uniforms: {
|
|
76512
|
+
'depthTexture': {
|
|
76513
|
+
value: null
|
|
76514
|
+
},
|
|
76515
|
+
'cameraNearFar': {
|
|
76516
|
+
value: new Vector2(0.5, 0.5)
|
|
76517
|
+
},
|
|
76518
|
+
'textureMatrix': {
|
|
76519
|
+
value: null
|
|
76520
|
+
}
|
|
76521
|
+
},
|
|
76522
|
+
vertexShader: "#include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n\n varying vec4 projTexCoord;\n varying vec4 vPosition;\n uniform mat4 textureMatrix;\n\n void main() {\n\n #include <skinbase_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n\n vPosition = mvPosition;\n vec4 worldPosition = modelMatrix * vec4(transformed, 1.0);\n projTexCoord = textureMatrix * worldPosition;\n\n }",
|
|
76523
|
+
fragmentShader: "#include <packing>\n varying vec4 vPosition;\n varying vec4 projTexCoord;\n uniform sampler2D depthTexture;\n uniform vec2 cameraNearFar;\n\n void main() {\n\n float depth = unpackRGBAToDepth(texture2DProj(depthTexture, projTexCoord));\n float viewZ = - DEPTH_TO_VIEW_Z(depth, cameraNearFar.x, cameraNearFar.y);\n float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n }"
|
|
76524
|
+
});
|
|
76525
|
+
}
|
|
76526
|
+
}, {
|
|
76527
|
+
key: "getEdgeDetectionMaterial",
|
|
76528
|
+
value: function getEdgeDetectionMaterial() {
|
|
76529
|
+
return new ShaderMaterial({
|
|
76530
|
+
uniforms: {
|
|
76531
|
+
'maskTexture': {
|
|
76532
|
+
value: null
|
|
76533
|
+
},
|
|
76534
|
+
'texSize': {
|
|
76535
|
+
value: new Vector2(0.5, 0.5)
|
|
76536
|
+
},
|
|
76537
|
+
'visibleEdgeColor': {
|
|
76538
|
+
value: new Vector3$1(1.0, 1.0, 1.0)
|
|
76539
|
+
},
|
|
76540
|
+
'hiddenEdgeColor': {
|
|
76541
|
+
value: new Vector3$1(1.0, 1.0, 1.0)
|
|
76542
|
+
}
|
|
76543
|
+
},
|
|
76544
|
+
vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",
|
|
76545
|
+
fragmentShader: "varying vec2 vUv;\n\n uniform sampler2D maskTexture;\n uniform vec2 texSize;\n uniform vec3 visibleEdgeColor;\n uniform vec3 hiddenEdgeColor;\n\n void main() {\n vec2 invSize = 1.0 / texSize;\n vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n vec4 c1 = texture2D(maskTexture, vUv + uvOffset.xy);\n vec4 c2 = texture2D(maskTexture, vUv - uvOffset.xy);\n vec4 c3 = texture2D(maskTexture, vUv + uvOffset.yw);\n vec4 c4 = texture2D(maskTexture, vUv - uvOffset.yw);\n float diff1 = (c1.r - c2.r)*0.5;\n float diff2 = (c3.r - c4.r)*0.5;\n float d = length(vec2(diff1, diff2));\n float a1 = min(c1.g, c2.g);\n float a2 = min(c3.g, c4.g);\n float visibilityFactor = min(a1, a2);\n vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n }"
|
|
76546
|
+
});
|
|
76547
|
+
}
|
|
76548
|
+
}, {
|
|
76549
|
+
key: "getSeperableBlurMaterial",
|
|
76550
|
+
value: function getSeperableBlurMaterial(maxRadius) {
|
|
76551
|
+
return new ShaderMaterial({
|
|
76552
|
+
defines: {
|
|
76553
|
+
'MAX_RADIUS': maxRadius
|
|
76554
|
+
},
|
|
76555
|
+
uniforms: {
|
|
76556
|
+
'colorTexture': {
|
|
76557
|
+
value: null
|
|
76558
|
+
},
|
|
76559
|
+
'texSize': {
|
|
76560
|
+
value: new Vector2(0.5, 0.5)
|
|
76561
|
+
},
|
|
76562
|
+
'direction': {
|
|
76563
|
+
value: new Vector2(0.5, 0.5)
|
|
76564
|
+
},
|
|
76565
|
+
'kernelRadius': {
|
|
76566
|
+
value: 1.0
|
|
76567
|
+
}
|
|
76568
|
+
},
|
|
76569
|
+
vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",
|
|
76570
|
+
fragmentShader: "#include <common>\n varying vec2 vUv;\n uniform sampler2D colorTexture;\n uniform vec2 texSize;\n uniform vec2 direction;\n uniform float kernelRadius;\n\n float gaussianPdf(in float x, in float sigma) {\n return 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n }\n\n void main() {\n vec2 invSize = 1.0 / texSize;\n float weightSum = gaussianPdf(0.0, kernelRadius);\n vec4 diffuseSum = texture2D(colorTexture, vUv) * weightSum;\n vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n vec2 uvOffset = delta;\n for(int i = 1; i <= MAX_RADIUS; i ++) {\n float w = gaussianPdf(uvOffset.x, kernelRadius);\n vec4 sample1 = texture2D(colorTexture, vUv + uvOffset);\n vec4 sample2 = texture2D(colorTexture, vUv - uvOffset);\n diffuseSum += ((sample1 + sample2) * w);\n weightSum += (2.0 * w);\n uvOffset += delta;\n }\n gl_FragColor = diffuseSum/weightSum;\n }"
|
|
76571
|
+
});
|
|
76572
|
+
}
|
|
76573
|
+
}, {
|
|
76574
|
+
key: "getOverlayMaterial",
|
|
76575
|
+
value: function getOverlayMaterial() {
|
|
76576
|
+
return new ShaderMaterial({
|
|
76577
|
+
uniforms: {
|
|
76578
|
+
'maskTexture': {
|
|
76579
|
+
value: null
|
|
76580
|
+
},
|
|
76581
|
+
'edgeTexture1': {
|
|
76582
|
+
value: null
|
|
76583
|
+
},
|
|
76584
|
+
'edgeTexture2': {
|
|
76585
|
+
value: null
|
|
76586
|
+
},
|
|
76587
|
+
'patternTexture': {
|
|
76588
|
+
value: null
|
|
76589
|
+
},
|
|
76590
|
+
'edgeStrength': {
|
|
76591
|
+
value: 1.0
|
|
76592
|
+
},
|
|
76593
|
+
'edgeGlow': {
|
|
76594
|
+
value: 1.0
|
|
76595
|
+
},
|
|
76596
|
+
'usePatternTexture': {
|
|
76597
|
+
value: 0.0
|
|
76598
|
+
}
|
|
76599
|
+
},
|
|
76600
|
+
vertexShader: "varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",
|
|
76601
|
+
fragmentShader: "varying vec2 vUv;\n\n uniform sampler2D maskTexture;\n uniform sampler2D edgeTexture1;\n uniform sampler2D edgeTexture2;\n uniform sampler2D patternTexture;\n uniform float edgeStrength;\n uniform float edgeGlow;\n uniform bool usePatternTexture;\n\n void main() {\n vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n vec4 maskColor = texture2D(maskTexture, vUv);\n vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n if(usePatternTexture)\n finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n gl_FragColor = finalColor;\n }",
|
|
76602
|
+
blending: AdditiveBlending,
|
|
76603
|
+
depthTest: false,
|
|
76604
|
+
depthWrite: false,
|
|
76605
|
+
transparent: true
|
|
76606
|
+
});
|
|
76607
|
+
}
|
|
76608
|
+
}]);
|
|
76609
|
+
|
|
76610
|
+
return SelectiveOutline;
|
|
76611
|
+
}(Pass);/**
|
|
76140
76612
|
* RGB Shift Shader
|
|
76141
76613
|
* Shifts red and blue channels from center in opposite directions
|
|
76142
76614
|
* Ported from http://kriss.cx/tom/2009/05/rgb-shift/
|
|
@@ -76213,7 +76685,7 @@ var DigitalGlitch = {
|
|
|
76213
76685
|
vertexShader: DigitalGlitch.vertexShader,
|
|
76214
76686
|
fragmentShader: DigitalGlitch.fragmentShader
|
|
76215
76687
|
});
|
|
76216
|
-
_this.fsQuad = new
|
|
76688
|
+
_this.fsQuad = new FullScreenQuad(_this.material);
|
|
76217
76689
|
_this.goWild = false;
|
|
76218
76690
|
_this.curF = 0;
|
|
76219
76691
|
|
|
@@ -76858,6 +77330,9 @@ var OutlineEffect = /*#__PURE__*/function () {
|
|
|
76858
77330
|
}), _defineProperty(_this$map, EFFECTS.DEPTH_OF_FIELD, {
|
|
76859
77331
|
effect: DepthOfField,
|
|
76860
77332
|
isClass: true
|
|
77333
|
+
}), _defineProperty(_this$map, EFFECTS.SELECTIVE_OUTLINE, {
|
|
77334
|
+
effect: SelectiveOutline,
|
|
77335
|
+
isClass: true
|
|
76861
77336
|
}), _defineProperty(_this$map, EFFECTS.GLITCH, {
|
|
76862
77337
|
effect: GlitchEffect,
|
|
76863
77338
|
isClass: true
|