Skip to content

Commit

Permalink
fix: build-time annotations for tree-shaking, sourcemaps (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Sep 23, 2023
1 parent 7bf780c commit ff8f2ff
Show file tree
Hide file tree
Showing 70 changed files with 239 additions and 255 deletions.
5 changes: 1 addition & 4 deletions src/_polyfill/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { REVISION } from 'three'

let _version: any = /* @__PURE__ */ REVISION.replace(/\D+/g, '')
_version = /* @__PURE__ */ parseInt(_version)

export const version = _version as number
export const version = parseInt(REVISION.replace(/\D+/g, ''))
22 changes: 11 additions & 11 deletions src/animation/CCDIKSolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import {
Vector3,
} from 'three'

const _q = /* @__PURE__ */ new Quaternion()
const _targetPos = /* @__PURE__ */ new Vector3()
const _targetVec = /* @__PURE__ */ new Vector3()
const _effectorPos = /* @__PURE__ */ new Vector3()
const _effectorVec = /* @__PURE__ */ new Vector3()
const _linkPos = /* @__PURE__ */ new Vector3()
const _invLinkQ = /* @__PURE__ */ new Quaternion()
const _linkScale = /* @__PURE__ */ new Vector3()
const _axis = /* @__PURE__ */ new Vector3()
const _vector = /* @__PURE__ */ new Vector3()
const _matrix = /* @__PURE__ */ new Matrix4()
const _q = new Quaternion()
const _targetPos = new Vector3()
const _targetVec = new Vector3()
const _effectorPos = new Vector3()
const _effectorVec = new Vector3()
const _linkPos = new Vector3()
const _invLinkQ = new Quaternion()
const _linkScale = new Vector3()
const _axis = new Vector3()
const _vector = new Vector3()
const _matrix = new Matrix4()

/**
* CCD Algorithm
Expand Down
2 changes: 1 addition & 1 deletion src/animation/MMDAnimationHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ class AudioManager {
}
}

const _q = /* @__PURE__ */ new Quaternion()
const _q = new Quaternion()

/**
* Solver for Grant (Fuyo in Japanese. I just google translated because
Expand Down
8 changes: 4 additions & 4 deletions src/animation/MMDPhysics.js
Original file line number Diff line number Diff line change
Expand Up @@ -1001,10 +1001,10 @@ class Constraint {
}
}

const _position = /* @__PURE__ */ new Vector3()
const _quaternion = /* @__PURE__ */ new Quaternion()
const _scale = /* @__PURE__ */ new Vector3()
const _matrixWorldInv = /* @__PURE__ */ new Matrix4()
const _position = new Vector3()
const _quaternion = new Quaternion()
const _scale = new Vector3()
const _matrixWorldInv = new Matrix4()

class MMDPhysicsHelper extends Object3D {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/controls/ArcballControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const _center = {

//transformation matrices for gizmos and camera
const _transformation: Transformation = {
camera: /* @__PURE__ */ new Matrix4(),
gizmos: /* @__PURE__ */ new Matrix4(),
camera: new Matrix4(),
gizmos: new Matrix4(),
}

//events
Expand Down
2 changes: 1 addition & 1 deletion src/controls/FirstPersonControls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MathUtils, Spherical, Vector3, EventDispatcher, Camera } from 'three'

const targetPosition = /* @__PURE__ */ new Vector3()
const targetPosition = new Vector3()

export class FirstPersonControls extends EventDispatcher {
public object: Camera
Expand Down
4 changes: 2 additions & 2 deletions src/controls/OrbitControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
Plane,
} from 'three'

const _ray = /* @__PURE__ */ new Ray()
const _plane = /* @__PURE__ */ new Plane()
const _ray = new Ray()
const _plane = new Plane()
const TILT_LIMIT = Math.cos(70 * (Math.PI / 180))

// This set of controls performs orbiting, dollying (zooming), and panning.
Expand Down
4 changes: 2 additions & 2 deletions src/controls/PointerLockControls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Euler, Camera, EventDispatcher, Vector3 } from 'three'

const _euler = /* @__PURE__ */ new Euler(0, 0, 0, 'YXZ')
const _vector = /* @__PURE__ */ new Vector3()
const _euler = new Euler(0, 0, 0, 'YXZ')
const _vector = new Vector3()
const _changeEvent = { type: 'change' }
const _lockEvent = { type: 'lock' }
const _unlockEvent = { type: 'unlock' }
Expand Down
8 changes: 4 additions & 4 deletions src/csm/CSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Vector2, Vector3, DirectionalLight, MathUtils, ShaderChunk, Matrix4, Bo
import { CSMFrustum } from './CSMFrustum'
import { CSMShader } from './CSMShader'

const _cameraToLightMatrix = /* @__PURE__ */ new Matrix4()
const _lightSpaceFrustum = /* @__PURE__ */ new CSMFrustum()
const _center = /* @__PURE__ */ new Vector3()
const _bbox = /* @__PURE__ */ new Box3()
const _cameraToLightMatrix = new Matrix4()
const _lightSpaceFrustum = new CSMFrustum()
const _center = new Vector3()
const _bbox = new Box3()
const _uniformArray = []
const _logArray = []

Expand Down
2 changes: 1 addition & 1 deletion src/csm/CSMFrustum.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Vector3, Matrix4 } from 'three'

const inverseProjectionMatrix = /* @__PURE__ */ new Matrix4()
const inverseProjectionMatrix = new Matrix4()

class CSMFrustum {
constructor(data) {
Expand Down
6 changes: 3 additions & 3 deletions src/deprecated/Geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
Vector3,
} from 'three'

const _m1 = /* @__PURE__ */ new Matrix4()
const _obj = /* @__PURE__ */ new Object3D()
const _offset = /* @__PURE__ */ new Vector3()
const _m1 = new Matrix4()
const _obj = new Object3D()
const _offset = new Vector3()

class Geometry extends EventDispatcher {
static createBufferGeometryFromObject(object) {
Expand Down
2 changes: 1 addition & 1 deletion src/geometries/RoundedBoxGeometry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BoxGeometry, Vector3 } from 'three'

const tempNormal = /* @__PURE__ */ new Vector3()
const tempNormal = new Vector3()

function getUv(faceDirVector, normal, uvAxis, projectionAxis, radius, sideLength) {
const totArcLength = (2 * Math.PI * radius) / 4
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/VertexNormalsHelper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BufferGeometry, Float32BufferAttribute, LineSegments, LineBasicMaterial, Matrix3, Vector3 } from 'three'

const _v1 = /* @__PURE__ */ new Vector3()
const _v2 = /* @__PURE__ */ new Vector3()
const _normalMatrix = /* @__PURE__ */ new Matrix3()
const _v1 = new Vector3()
const _v2 = new Vector3()
const _normalMatrix = new Matrix3()

class VertexNormalsHelper extends LineSegments {
constructor(object, size = 1, color = 0xff0000) {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/VertexTangentsHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BufferGeometry, Float32BufferAttribute, LineSegments, LineBasicMaterial, Vector3 } from 'three'

const _v1 = /* @__PURE__ */ new Vector3()
const _v2 = /* @__PURE__ */ new Vector3()
const _v1 = new Vector3()
const _v2 = new Vector3()

class VertexTangentsHelper extends LineSegments {
constructor(object, size = 1, color = 0x00ffff) {
Expand Down
2 changes: 1 addition & 1 deletion src/interactive/InteractiveGroup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Group, Matrix4, Raycaster, Vector2 } from 'three'

const _pointer = /* @__PURE__ */ new Vector2()
const _pointer = new Vector2()
const _event = { type: '', data: _pointer }

class InteractiveGroup extends Group {
Expand Down
30 changes: 15 additions & 15 deletions src/interactive/SelectionBox.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Frustum, Vector3 } from 'three'

const frustum = /* @__PURE__ */ new Frustum()
const center = /* @__PURE__ */ new Vector3()
const frustum = new Frustum()
const center = new Vector3()

const tmpPoint = /* @__PURE__ */ new Vector3()
const tmpPoint = new Vector3()

const vecNear = /* @__PURE__ */ new Vector3()
const vecTopLeft = /* @__PURE__ */ new Vector3()
const vecTopRight = /* @__PURE__ */ new Vector3()
const vecDownRight = /* @__PURE__ */ new Vector3()
const vecDownLeft = /* @__PURE__ */ new Vector3()
const vecNear = new Vector3()
const vecTopLeft = new Vector3()
const vecTopRight = new Vector3()
const vecDownRight = new Vector3()
const vecDownLeft = new Vector3()

const vecFarTopLeft = /* @__PURE__ */ new Vector3()
const vecFarTopRight = /* @__PURE__ */ new Vector3()
const vecFarDownRight = /* @__PURE__ */ new Vector3()
const vecFarDownLeft = /* @__PURE__ */ new Vector3()
const vecFarTopLeft = new Vector3()
const vecFarTopRight = new Vector3()
const vecFarDownRight = new Vector3()
const vecFarDownLeft = new Vector3()

const vectemp1 = /* @__PURE__ */ new Vector3()
const vectemp2 = /* @__PURE__ */ new Vector3()
const vectemp3 = /* @__PURE__ */ new Vector3()
const vectemp1 = new Vector3()
const vectemp2 = new Vector3()
const vectemp3 = new Vector3()

class SelectionBox {
constructor(camera, scene, deep) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/chevrotain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { CstParser, Lexer, createToken } = /* @__PURE__ */ (() => {
const { CstParser, Lexer, createToken } = (() => {
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global

Expand Down
24 changes: 12 additions & 12 deletions src/lines/LineSegments2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import {
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'
import { LineMaterial } from '../lines/LineMaterial'

const _start = /* @__PURE__ */ new Vector3()
const _end = /* @__PURE__ */ new Vector3()
const _start = new Vector3()
const _end = new Vector3()

const _start4 = /* @__PURE__ */ new Vector4()
const _end4 = /* @__PURE__ */ new Vector4()
const _start4 = new Vector4()
const _end4 = new Vector4()

const _ssOrigin = /* @__PURE__ */ new Vector4()
const _ssOrigin3 = /* @__PURE__ */ new Vector3()
const _mvMatrix = /* @__PURE__ */ new Matrix4()
const _line = /* @__PURE__ */ new Line3()
const _closestPoint = /* @__PURE__ */ new Vector3()
const _ssOrigin = new Vector4()
const _ssOrigin3 = new Vector3()
const _mvMatrix = new Matrix4()
const _line = new Line3()
const _closestPoint = new Vector3()

const _box = /* @__PURE__ */ new Box3()
const _sphere = /* @__PURE__ */ new Sphere()
const _clipToWorldVector = /* @__PURE__ */ new Vector4()
const _box = new Box3()
const _sphere = new Sphere()
const _clipToWorldVector = new Vector4()

let _ray, _instanceStart, _instanceEnd, _lineWidth

Expand Down
4 changes: 2 additions & 2 deletions src/lines/LineSegmentsGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
WireframeGeometry,
} from 'three'

const _box = /* @__PURE__ */ new Box3()
const _vector = /* @__PURE__ */ new Vector3()
const _box = new Box3()
const _vector = new Vector3()

class LineSegmentsGeometry extends InstancedBufferGeometry {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions src/lines/Wireframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { InstancedInterleavedBuffer, InterleavedBufferAttribute, Mesh, Vector3 }
import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'
import { LineMaterial } from '../lines/LineMaterial'

const _start = /* @__PURE__ */ new Vector3()
const _end = /* @__PURE__ */ new Vector3()
const _start = new Vector3()
const _end = new Vector3()

class Wireframe extends Mesh {
constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) {
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/EXRLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import { unzlibSync } from 'fflate'

// // End of OpenEXR license -------------------------------------------------

const hasColorSpace = 'colorSpace' in /* @__PURE__ */ new Texture()
const hasColorSpace = 'colorSpace' in new Texture()

class EXRLoader extends DataTextureLoader {
constructor(manager) {
Expand Down
4 changes: 2 additions & 2 deletions src/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3116,8 +3116,8 @@ function getData(polygonVertexIndex, polygonIndex, vertexIndex, infoObject) {
return slice(dataArray, infoObject.buffer, from, to)
}

const tempEuler = /* @__PURE__ */ new Euler()
const tempVec = /* @__PURE__ */ new Vector3()
const tempEuler = new Euler()
const tempVec = new Vector3()

// generate transformation from FBX transform data
// ref: https://help.autodesk.com/view/FBX/2017/ENU/?guid=__files_GUID_10CDD63C_79C1_4F2D_BB28_AD2BE65A02ED_htm
Expand Down
4 changes: 2 additions & 2 deletions src/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ class GLTFCubicSplineInterpolant extends Interpolant {
}
}

const _q = /* @__PURE__ */ new Quaternion()
const _q = new Quaternion()

class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
interpolate_(i1, t0, t, t1) {
Expand Down Expand Up @@ -1890,7 +1890,7 @@ function getImageURIMimeType(uri) {
return 'image/png'
}

const _identityMatrix = /* @__PURE__ */ new Matrix4()
const _identityMatrix = new Matrix4()

/* GLTF PARSER */

Expand Down
6 changes: 3 additions & 3 deletions src/loaders/LDrawLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const FILE_LOCATION_NOT_FOUND = 6
const MAIN_COLOUR_CODE = '16'
const MAIN_EDGE_COLOUR_CODE = '24'

const _tempVec0 = /* @__PURE__ */ new Vector3()
const _tempVec1 = /* @__PURE__ */ new Vector3()
const _tempVec0 = new Vector3()
const _tempVec1 = new Vector3()

class LDrawConditionalLineMaterial extends ShaderMaterial {
constructor(parameters) {
Expand Down Expand Up @@ -180,7 +180,7 @@ function generateFaceNormals(faces) {
}
}

const _ray = /* @__PURE__ */ new Ray()
const _ray = new Ray()
function smoothNormals(faces, lineSegments, checkSubSegments = false) {
// NOTE: 1e2 is pretty coarse but was chosen to quantize the resulting value because
// it allows edges to be smoothed as expected (see minifig arms).
Expand Down
10 changes: 5 additions & 5 deletions src/loaders/OBJLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const _material_use_pattern = /^usemtl /
// usemap map_name
const _map_use_pattern = /^usemap /

const _vA = /* @__PURE__ */ new Vector3()
const _vB = /* @__PURE__ */ new Vector3()
const _vC = /* @__PURE__ */ new Vector3()
const _vA = new Vector3()
const _vB = new Vector3()
const _vC = new Vector3()

const _ab = /* @__PURE__ */ new Vector3()
const _cb = /* @__PURE__ */ new Vector3()
const _ab = new Vector3()
const _cb = new Vector3()

function ParserState() {
const state = {
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/TiltLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ const shaders = () => ({
Light: {
uniforms: {
mainTex: {
value: /* @__PURE__ */ new TextureLoader().setPath('./textures/tiltbrush/').loader.load('Light.webp'),
value: new TextureLoader().setPath('./textures/tiltbrush/').loader.load('Light.webp'),
},
alphaTest: { value: 0.067 },
emission_gain: { value: 0.45 },
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/XLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
Vector3,
} from 'three'

var XLoader = /* @__PURE__ */ (function () {
var XLoader = (function () {
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function')
Expand Down
6 changes: 3 additions & 3 deletions src/math/Capsule.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Vector3 } from 'three'

const _v1 = /* @__PURE__ */ new Vector3()
const _v2 = /* @__PURE__ */ new Vector3()
const _v3 = /* @__PURE__ */ new Vector3()
const _v1 = new Vector3()
const _v2 = new Vector3()
const _v3 = new Vector3()

const EPS = 1e-10

Expand Down
10 changes: 5 additions & 5 deletions src/math/ConvexHull.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { Line3, Plane, Triangle, Vector3 } from 'three'
const Visible = 0
const Deleted = 1

const _v1 = /* @__PURE__ */ new Vector3()
const _line3 = /* @__PURE__ */ new Line3()
const _plane = /* @__PURE__ */ new Plane()
const _closestPoint = /* @__PURE__ */ new Vector3()
const _triangle = /* @__PURE__ */ new Triangle()
const _v1 = new Vector3()
const _line3 = new Line3()
const _plane = new Plane()
const _closestPoint = new Vector3()
const _triangle = new Triangle()

class ConvexHull {
constructor() {
Expand Down
Loading

0 comments on commit ff8f2ff

Please sign in to comment.