|
|
@@ -29,6 +29,8 @@ import { Vector4 } from '../../math/Vector4.js';
|
|
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
|
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, LinearSRGBColorSpace, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
|
|
|
|
|
|
+import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
|
+
|
|
|
const _scene = /*@__PURE__*/ new Scene();
|
|
|
const _drawingBufferSize = /*@__PURE__*/ new Vector2();
|
|
|
const _screen = /*@__PURE__*/ new Vector4();
|
|
|
@@ -230,7 +232,15 @@ class Renderer {
|
|
|
*/
|
|
|
this.info = new Info();
|
|
|
|
|
|
- this.nodes = {
|
|
|
+ /**
|
|
|
+ * Stores override nodes for specific transformations or calculations.
|
|
|
+ * These nodes can be used to replace default behavior in the rendering pipeline.
|
|
|
+ *
|
|
|
+ * @type {Object}
|
|
|
+ * @property {?Node} modelViewMatrix - An override node for the model-view matrix.
|
|
|
+ * @property {?Node} modelNormalViewMatrix - An override node for the model normal view matrix.
|
|
|
+ */
|
|
|
+ this.overrideNodes = {
|
|
|
modelViewMatrix: null,
|
|
|
modelNormalViewMatrix: null
|
|
|
};
|
|
|
@@ -982,6 +992,43 @@ class Renderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Enables or disables high precision for model-view and normal-view matrices.
|
|
|
+ * When enabled, will use CPU 64-bit precision for higher precision instead of GPU 32-bit for higher performance.
|
|
|
+ *
|
|
|
+ * NOTE: 64-bit precision is not compatible with `InstancedMesh` and `SkinnedMesh`.
|
|
|
+ *
|
|
|
+ * @param {boolean} value - Whether to enable or disable high precision.
|
|
|
+ * @type {boolean}
|
|
|
+ */
|
|
|
+ set highPrecision( value ) {
|
|
|
+
|
|
|
+ if ( value === true ) {
|
|
|
+
|
|
|
+ this.overrideNodes.modelViewMatrix = highpModelViewMatrix;
|
|
|
+ this.overrideNodes.modelNormalViewMatrix = highpModelNormalViewMatrix;
|
|
|
+
|
|
|
+ } else if ( this.highPrecision ) {
|
|
|
+
|
|
|
+ this.overrideNodes.modelViewMatrix = null;
|
|
|
+ this.overrideNodes.modelNormalViewMatrix = null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns whether high precision is enabled or not.
|
|
|
+ *
|
|
|
+ * @return {boolean} Whether high precision is enabled or not.
|
|
|
+ * @type {boolean}
|
|
|
+ */
|
|
|
+ get highPrecision() {
|
|
|
+
|
|
|
+ return this.overrideNodes.modelViewMatrix === highpModelViewMatrix && this.overrideNodes.modelNormalViewMatrix === highpModelNormalViewMatrix;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Sets the given MRT configuration.
|
|
|
*
|