@math.gl/culling
Advanced tools
Comparing version 3.1.1 to 3.1.2
@@ -10,4 +10,2 @@ "use strict"; | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -73,7 +71,7 @@ | ||
if (!plane0) { | ||
plane0 = this.planes[planeIndex] = new _math.Vector4(); | ||
plane0 = this.planes[planeIndex] = new _plane["default"](); | ||
} | ||
if (!plane1) { | ||
plane1 = this.planes[planeIndex + 1] = new _math.Vector4(); | ||
plane1 = this.planes[planeIndex + 1] = new _plane["default"](); | ||
} | ||
@@ -83,13 +81,7 @@ | ||
var plane0Distance = -faceNormal.dot(plane0Center); | ||
plane0.x = faceNormal.x; | ||
plane0.y = faceNormal.y; | ||
plane0.z = faceNormal.z; | ||
plane0.w = plane0Distance; | ||
plane0.fromPointNormal(plane0Center, faceNormal); | ||
var plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center); | ||
var negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate(); | ||
var plane1Distance = -negatedFaceNormal.dot(plane1Center); | ||
plane1.x = negatedFaceNormal.x; | ||
plane1.y = negatedFaceNormal.y; | ||
plane1.z = negatedFaceNormal.z; | ||
plane1.w = plane1Distance; | ||
plane1.fromPointNormal(plane1Center, negatedFaceNormal); | ||
planeIndex += 2; | ||
@@ -125,4 +117,3 @@ } | ||
for (var _iterator2 = this.planes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var planeCoefficients = _step2.value; | ||
var plane = scratchPlane.fromCoefficients.apply(scratchPlane, (0, _toConsumableArray2["default"])(planeCoefficients)); | ||
var plane = _step2.value; | ||
var result = boundingVolume.intersectPlane(plane); | ||
@@ -178,3 +169,3 @@ | ||
var plane = scratchPlane.fromCoefficients.apply(scratchPlane, (0, _toConsumableArray2["default"])(planes[k])); | ||
var plane = planes[k]; | ||
var result = boundingVolume.intersectPlane(plane); | ||
@@ -181,0 +172,0 @@ |
@@ -20,2 +20,4 @@ "use strict"; | ||
var _plane = _interopRequireDefault(require("./plane")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -25,2 +27,3 @@ | ||
var scratchPlaneUpVector = new _math.Vector3(); | ||
var scratchPlaneRightVector = new _math.Vector3(); | ||
@@ -51,3 +54,3 @@ var scratchPlaneNearCenter = new _math.Vector3(); | ||
this._far = this.far; | ||
this._cullingVolume = new _cullingVolume["default"](); | ||
this._cullingVolume = new _cullingVolume["default"]([new _plane["default"](), new _plane["default"](), new _plane["default"](), new _plane["default"](), new _plane["default"](), new _plane["default"]()]); | ||
this._perspectiveMatrix = new _math.Matrix4(); | ||
@@ -81,48 +84,19 @@ this._infinitePerspective = new _math.Matrix4(); | ||
var planes = this._cullingVolume.planes; | ||
var right = scratchPlaneRightVector.copy(direction).cross(up); | ||
up = scratchPlaneUpVector.copy(up).normalize(); | ||
var right = scratchPlaneRightVector.copy(direction).cross(up).normalize(); | ||
var nearCenter = scratchPlaneNearCenter.copy(direction).multiplyByScalar(this.near).add(position); | ||
var farCenter = scratchPlaneFarCenter.copy(direction).multiplyByScalar(this.far).add(position); | ||
var normal = scratchPlaneNormal; | ||
normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).normalize().cross(up).normalize(); | ||
planes[0] = planes[0] || new _math.Vector4(); | ||
var plane = planes[0]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(right).multiplyByScalar(this.right).add(nearCenter).subtract(position).normalize().cross(up).normalize(); | ||
planes[1] = planes[1] || new _math.Vector4(); | ||
plane = planes[1]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(up).multiplyByScalar(this.bottom).add(nearCenter).subtract(position).normalize().cross(right).normalize(); | ||
planes[2] = planes[2] || new _math.Vector4(); | ||
plane = planes[2]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).normalize().cross(right).normalize(); | ||
planes[3] = planes[3] || new _math.Vector4(); | ||
plane = planes[3]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal = new _math.Vector3().copy(direction).normalize(); | ||
planes[4] = planes[4] || new _math.Vector4(); | ||
plane = planes[4]; | ||
plane.x = direction.x; | ||
plane.y = direction.y; | ||
plane.z = direction.z; | ||
plane.w = -direction.dot(nearCenter); | ||
normal.copy(direction).negate().normalize(); | ||
planes[5] = planes[5] || new _math.Vector4(); | ||
plane = planes[5]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(farCenter); | ||
normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).cross(up); | ||
planes[0].fromPointNormal(position, normal); | ||
normal.copy(right).multiplyByScalar(this.right).add(nearCenter).subtract(position).cross(up).negate(); | ||
planes[1].fromPointNormal(position, normal); | ||
normal.copy(up).multiplyByScalar(this.bottom).add(nearCenter).subtract(position).cross(right).negate(); | ||
planes[2].fromPointNormal(position, normal); | ||
normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).cross(right); | ||
planes[3].fromPointNormal(position, normal); | ||
normal = new _math.Vector3().copy(direction); | ||
planes[4].fromPointNormal(nearCenter, normal); | ||
normal.negate(); | ||
planes[5].fromPointNormal(farCenter, normal); | ||
return this._cullingVolume; | ||
@@ -129,0 +103,0 @@ } |
@@ -50,3 +50,3 @@ "use strict"; | ||
this.normal.set(a, b, c); | ||
(0, _math.assert)(this.normal.len() === 1); | ||
(0, _math.assert)((0, _math.equals)(this.normal.len(), 1)); | ||
this.distance = d; | ||
@@ -53,0 +53,0 @@ return this; |
@@ -37,7 +37,7 @@ import { Vector3, Vector4, assert } from 'math.gl'; | ||
if (!plane0) { | ||
plane0 = this.planes[planeIndex] = new Vector4(); | ||
plane0 = this.planes[planeIndex] = new Plane(); | ||
} | ||
if (!plane1) { | ||
plane1 = this.planes[planeIndex + 1] = new Vector4(); | ||
plane1 = this.planes[planeIndex + 1] = new Plane(); | ||
} | ||
@@ -47,13 +47,7 @@ | ||
const plane0Distance = -faceNormal.dot(plane0Center); | ||
plane0.x = faceNormal.x; | ||
plane0.y = faceNormal.y; | ||
plane0.z = faceNormal.z; | ||
plane0.w = plane0Distance; | ||
plane0.fromPointNormal(plane0Center, faceNormal); | ||
const plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center); | ||
const negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate(); | ||
const plane1Distance = -negatedFaceNormal.dot(plane1Center); | ||
plane1.x = negatedFaceNormal.x; | ||
plane1.y = negatedFaceNormal.y; | ||
plane1.z = negatedFaceNormal.z; | ||
plane1.w = plane1Distance; | ||
plane1.fromPointNormal(plane1Center, negatedFaceNormal); | ||
planeIndex += 2; | ||
@@ -69,4 +63,3 @@ } | ||
for (const planeCoefficients of this.planes) { | ||
const plane = scratchPlane.fromCoefficients(...planeCoefficients); | ||
for (const plane of this.planes) { | ||
const result = boundingVolume.intersectPlane(plane); | ||
@@ -107,3 +100,3 @@ | ||
const plane = scratchPlane.fromCoefficients(...planes[k]); | ||
const plane = planes[k]; | ||
const result = boundingVolume.intersectPlane(plane); | ||
@@ -110,0 +103,0 @@ |
@@ -7,4 +7,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import { Vector3, Vector4, Matrix4, assert } from 'math.gl'; | ||
import { Vector3, Matrix4, assert } from 'math.gl'; | ||
import CullingVolume from './culling-volume'; | ||
import Plane from './plane'; | ||
const scratchPlaneUpVector = new Vector3(); | ||
const scratchPlaneRightVector = new Vector3(); | ||
@@ -32,3 +34,3 @@ const scratchPlaneNearCenter = new Vector3(); | ||
this._far = this.far; | ||
this._cullingVolume = new CullingVolume(); | ||
this._cullingVolume = new CullingVolume([new Plane(), new Plane(), new Plane(), new Plane(), new Plane(), new Plane()]); | ||
this._perspectiveMatrix = new Matrix4(); | ||
@@ -68,48 +70,19 @@ this._infinitePerspective = new Matrix4(); | ||
const planes = this._cullingVolume.planes; | ||
const right = scratchPlaneRightVector.copy(direction).cross(up); | ||
up = scratchPlaneUpVector.copy(up).normalize(); | ||
const right = scratchPlaneRightVector.copy(direction).cross(up).normalize(); | ||
const nearCenter = scratchPlaneNearCenter.copy(direction).multiplyByScalar(this.near).add(position); | ||
const farCenter = scratchPlaneFarCenter.copy(direction).multiplyByScalar(this.far).add(position); | ||
let normal = scratchPlaneNormal; | ||
normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).normalize().cross(up).normalize(); | ||
planes[0] = planes[0] || new Vector4(); | ||
let plane = planes[0]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(right).multiplyByScalar(this.right).add(nearCenter).subtract(position).normalize().cross(up).normalize(); | ||
planes[1] = planes[1] || new Vector4(); | ||
plane = planes[1]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(up).multiplyByScalar(this.bottom).add(nearCenter).subtract(position).normalize().cross(right).normalize(); | ||
planes[2] = planes[2] || new Vector4(); | ||
plane = planes[2]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).normalize().cross(right).normalize(); | ||
planes[3] = planes[3] || new Vector4(); | ||
plane = planes[3]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal = new Vector3().copy(direction).normalize(); | ||
planes[4] = planes[4] || new Vector4(); | ||
plane = planes[4]; | ||
plane.x = direction.x; | ||
plane.y = direction.y; | ||
plane.z = direction.z; | ||
plane.w = -direction.dot(nearCenter); | ||
normal.copy(direction).negate().normalize(); | ||
planes[5] = planes[5] || new Vector4(); | ||
plane = planes[5]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(farCenter); | ||
normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).cross(up); | ||
planes[0].fromPointNormal(position, normal); | ||
normal.copy(right).multiplyByScalar(this.right).add(nearCenter).subtract(position).cross(up).negate(); | ||
planes[1].fromPointNormal(position, normal); | ||
normal.copy(up).multiplyByScalar(this.bottom).add(nearCenter).subtract(position).cross(right).negate(); | ||
planes[2].fromPointNormal(position, normal); | ||
normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).cross(right); | ||
planes[3].fromPointNormal(position, normal); | ||
normal = new Vector3().copy(direction); | ||
planes[4].fromPointNormal(nearCenter, normal); | ||
normal.negate(); | ||
planes[5].fromPointNormal(farCenter, normal); | ||
return this._cullingVolume; | ||
@@ -116,0 +89,0 @@ } |
@@ -28,3 +28,3 @@ import { Vector3, equals, assert, MathUtils } from 'math.gl'; | ||
this.normal.set(a, b, c); | ||
assert(this.normal.len() === 1); | ||
assert(equals(this.normal.len(), 1)); | ||
this.distance = d; | ||
@@ -31,0 +31,0 @@ return this; |
@@ -1,2 +0,1 @@ | ||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
@@ -59,7 +58,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
if (!plane0) { | ||
plane0 = this.planes[planeIndex] = new Vector4(); | ||
plane0 = this.planes[planeIndex] = new Plane(); | ||
} | ||
if (!plane1) { | ||
plane1 = this.planes[planeIndex + 1] = new Vector4(); | ||
plane1 = this.planes[planeIndex + 1] = new Plane(); | ||
} | ||
@@ -69,13 +68,7 @@ | ||
var plane0Distance = -faceNormal.dot(plane0Center); | ||
plane0.x = faceNormal.x; | ||
plane0.y = faceNormal.y; | ||
plane0.z = faceNormal.z; | ||
plane0.w = plane0Distance; | ||
plane0.fromPointNormal(plane0Center, faceNormal); | ||
var plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center); | ||
var negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate(); | ||
var plane1Distance = -negatedFaceNormal.dot(plane1Center); | ||
plane1.x = negatedFaceNormal.x; | ||
plane1.y = negatedFaceNormal.y; | ||
plane1.z = negatedFaceNormal.z; | ||
plane1.w = plane1Distance; | ||
plane1.fromPointNormal(plane1Center, negatedFaceNormal); | ||
planeIndex += 2; | ||
@@ -111,4 +104,3 @@ } | ||
for (var _iterator2 = this.planes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var planeCoefficients = _step2.value; | ||
var plane = scratchPlane.fromCoefficients.apply(scratchPlane, _toConsumableArray(planeCoefficients)); | ||
var plane = _step2.value; | ||
var result = boundingVolume.intersectPlane(plane); | ||
@@ -164,3 +156,3 @@ | ||
var plane = scratchPlane.fromCoefficients.apply(scratchPlane, _toConsumableArray(planes[k])); | ||
var plane = planes[k]; | ||
var result = boundingVolume.intersectPlane(plane); | ||
@@ -167,0 +159,0 @@ |
@@ -9,4 +9,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import { Vector3, Vector4, Matrix4, assert } from 'math.gl'; | ||
import { Vector3, Matrix4, assert } from 'math.gl'; | ||
import CullingVolume from './culling-volume'; | ||
import Plane from './plane'; | ||
var scratchPlaneUpVector = new Vector3(); | ||
var scratchPlaneRightVector = new Vector3(); | ||
@@ -39,3 +41,3 @@ var scratchPlaneNearCenter = new Vector3(); | ||
this._far = this.far; | ||
this._cullingVolume = new CullingVolume(); | ||
this._cullingVolume = new CullingVolume([new Plane(), new Plane(), new Plane(), new Plane(), new Plane(), new Plane()]); | ||
this._perspectiveMatrix = new Matrix4(); | ||
@@ -69,48 +71,19 @@ this._infinitePerspective = new Matrix4(); | ||
var planes = this._cullingVolume.planes; | ||
var right = scratchPlaneRightVector.copy(direction).cross(up); | ||
up = scratchPlaneUpVector.copy(up).normalize(); | ||
var right = scratchPlaneRightVector.copy(direction).cross(up).normalize(); | ||
var nearCenter = scratchPlaneNearCenter.copy(direction).multiplyByScalar(this.near).add(position); | ||
var farCenter = scratchPlaneFarCenter.copy(direction).multiplyByScalar(this.far).add(position); | ||
var normal = scratchPlaneNormal; | ||
normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).normalize().cross(up).normalize(); | ||
planes[0] = planes[0] || new Vector4(); | ||
var plane = planes[0]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(right).multiplyByScalar(this.right).add(nearCenter).subtract(position).normalize().cross(up).normalize(); | ||
planes[1] = planes[1] || new Vector4(); | ||
plane = planes[1]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(up).multiplyByScalar(this.bottom).add(nearCenter).subtract(position).normalize().cross(right).normalize(); | ||
planes[2] = planes[2] || new Vector4(); | ||
plane = planes[2]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).normalize().cross(right).normalize(); | ||
planes[3] = planes[3] || new Vector4(); | ||
plane = planes[3]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
normal = new Vector3().copy(direction).normalize(); | ||
planes[4] = planes[4] || new Vector4(); | ||
plane = planes[4]; | ||
plane.x = direction.x; | ||
plane.y = direction.y; | ||
plane.z = direction.z; | ||
plane.w = -direction.dot(nearCenter); | ||
normal.copy(direction).negate().normalize(); | ||
planes[5] = planes[5] || new Vector4(); | ||
plane = planes[5]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(farCenter); | ||
normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).cross(up); | ||
planes[0].fromPointNormal(position, normal); | ||
normal.copy(right).multiplyByScalar(this.right).add(nearCenter).subtract(position).cross(up).negate(); | ||
planes[1].fromPointNormal(position, normal); | ||
normal.copy(up).multiplyByScalar(this.bottom).add(nearCenter).subtract(position).cross(right).negate(); | ||
planes[2].fromPointNormal(position, normal); | ||
normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).cross(right); | ||
planes[3].fromPointNormal(position, normal); | ||
normal = new Vector3().copy(direction); | ||
planes[4].fromPointNormal(nearCenter, normal); | ||
normal.negate(); | ||
planes[5].fromPointNormal(farCenter, normal); | ||
return this._cullingVolume; | ||
@@ -117,0 +90,0 @@ } |
@@ -40,3 +40,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
this.normal.set(a, b, c); | ||
assert(this.normal.len() === 1); | ||
assert(_equals(this.normal.len(), 1)); | ||
this.distance = d; | ||
@@ -43,0 +43,0 @@ return this; |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"keywords": [ | ||
@@ -39,6 +39,6 @@ "webgl", | ||
"@babel/runtime": "^7.0.0", | ||
"@math.gl/core": "3.1.1", | ||
"@math.gl/core": "3.1.2", | ||
"gl-matrix": "^3.0.0" | ||
}, | ||
"gitHead": "2b3d9073ab38524efa00da5df72fcd0eb61fd2c9" | ||
"gitHead": "badc6fa51d047dbbc843f337ecd79506bba6671e" | ||
} |
@@ -57,6 +57,6 @@ // This file is derived from the Cesium math library under Apache 2 license | ||
if (!plane0) { | ||
plane0 = this.planes[planeIndex] = new Vector4(); | ||
plane0 = this.planes[planeIndex] = new Plane(); | ||
} | ||
if (!plane1) { | ||
plane1 = this.planes[planeIndex + 1] = new Vector4(); | ||
plane1 = this.planes[planeIndex + 1] = new Plane(); | ||
} | ||
@@ -70,7 +70,3 @@ | ||
// plane0.fromNormalDistance(faceNormal, plane0Distance); | ||
plane0.x = faceNormal.x; | ||
plane0.y = faceNormal.y; | ||
plane0.z = faceNormal.z; | ||
plane0.w = plane0Distance; | ||
plane0.fromPointNormal(plane0Center, faceNormal); | ||
@@ -86,7 +82,3 @@ const plane1Center = scratchPlaneCenter | ||
// plane1.fromNormalDistance(negatedFaceNormal, plane1Distance); | ||
plane1.x = negatedFaceNormal.x; | ||
plane1.y = negatedFaceNormal.y; | ||
plane1.z = negatedFaceNormal.z; | ||
plane1.w = plane1Distance; | ||
plane1.fromPointNormal(plane1Center, negatedFaceNormal); | ||
@@ -104,4 +96,3 @@ planeIndex += 2; | ||
let intersect = Intersect.INSIDE; | ||
for (const planeCoefficients of this.planes) { | ||
const plane = scratchPlane.fromCoefficients(...planeCoefficients); | ||
for (const plane of this.planes) { | ||
const result = boundingVolume.intersectPlane(plane); | ||
@@ -157,3 +148,3 @@ switch (result) { | ||
const plane = scratchPlane.fromCoefficients(...planes[k]); | ||
const plane = planes[k]; | ||
const result = boundingVolume.intersectPlane(plane); | ||
@@ -160,0 +151,0 @@ if (result === Intersect.OUTSIDE) { |
@@ -8,5 +8,7 @@ // This file is derived from the Cesium math library under Apache 2 license | ||
import {Vector3, Vector4, Matrix4, assert} from 'math.gl'; | ||
import {Vector3, Matrix4, assert} from 'math.gl'; | ||
import CullingVolume from './culling-volume'; | ||
import Plane from './plane'; | ||
const scratchPlaneUpVector = new Vector3(); | ||
const scratchPlaneRightVector = new Vector3(); | ||
@@ -98,3 +100,10 @@ const scratchPlaneNearCenter = new Vector3(); | ||
this._cullingVolume = new CullingVolume(); | ||
this._cullingVolume = new CullingVolume([ | ||
new Plane(), | ||
new Plane(), | ||
new Plane(), | ||
new Plane(), | ||
new Plane(), | ||
new Plane() | ||
]); | ||
this._perspectiveMatrix = new Matrix4(); | ||
@@ -186,3 +195,7 @@ this._infinitePerspective = new Matrix4(); | ||
const right = scratchPlaneRightVector.copy(direction).cross(up); | ||
up = scratchPlaneUpVector.copy(up).normalize(); | ||
const right = scratchPlaneRightVector | ||
.copy(direction) | ||
.cross(up) | ||
.normalize(); | ||
@@ -207,12 +220,5 @@ const nearCenter = scratchPlaneNearCenter | ||
.subtract(position) | ||
.normalize() | ||
.cross(up) | ||
.normalize(); | ||
.cross(up); | ||
planes[0] = planes[0] || new Vector4(); | ||
let plane = planes[0]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
planes[0].fromPointNormal(position, normal); | ||
@@ -225,12 +231,6 @@ // Right plane computation | ||
.subtract(position) | ||
.normalize() | ||
.cross(up) | ||
.normalize(); | ||
.negate(); | ||
planes[1] = planes[1] || new Vector4(); | ||
plane = planes[1]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
planes[1].fromPointNormal(position, normal); | ||
@@ -243,12 +243,6 @@ // Bottom plane computation | ||
.subtract(position) | ||
.normalize() | ||
.cross(right) | ||
.normalize(); | ||
.negate(); | ||
planes[2] = planes[2] || new Vector4(); | ||
plane = planes[2]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
planes[2].fromPointNormal(position, normal); | ||
@@ -261,35 +255,15 @@ // Top plane computation | ||
.subtract(position) | ||
.normalize() | ||
.cross(right) | ||
.normalize(); | ||
.cross(right); | ||
planes[3] = planes[3] || new Vector4(); | ||
plane = planes[3]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(position); | ||
planes[3].fromPointNormal(position, normal); | ||
normal = new Vector3().copy(direction).normalize(); | ||
normal = new Vector3().copy(direction); | ||
// Near plane computation | ||
planes[4] = planes[4] || new Vector4(); | ||
plane = planes[4]; | ||
plane.x = direction.x; | ||
plane.y = direction.y; | ||
plane.z = direction.z; | ||
plane.w = -direction.dot(nearCenter); | ||
planes[4].fromPointNormal(nearCenter, normal); | ||
// Far plane computation | ||
normal | ||
.copy(direction) | ||
.negate() | ||
.normalize(); | ||
normal.negate(); | ||
planes[5] = planes[5] || new Vector4(); | ||
plane = planes[5]; | ||
plane.x = normal.x; | ||
plane.y = normal.y; | ||
plane.z = normal.z; | ||
plane.w = -normal.dot(farCenter); | ||
planes[5].fromPointNormal(farCenter, normal); | ||
@@ -296,0 +270,0 @@ return this._cullingVolume; |
@@ -38,3 +38,3 @@ // This file is derived from the Cesium math library under Apache 2 license | ||
this.normal.set(a, b, c); | ||
assert(this.normal.len() === 1); | ||
assert(equals(this.normal.len(), 1)); | ||
this.distance = d; | ||
@@ -41,0 +41,0 @@ return this; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
701204
6133
+ Added@math.gl/core@3.1.2(transitive)
- Removed@math.gl/core@3.1.1(transitive)
Updated@math.gl/core@3.1.2