Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify threejs imports #53

Merged
merged 4 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### MathBox Changelog

### 2.2.2 (unreleased)

- Changed how Mathbox imports ThreeJS. Previously, Mathbox (usually) imported from `three/src`. Now it consistently imports from `three`. This change should generally not affect users unless they were using `instanceof` checks.

### 2.2.1
- Add Typescript support for live properties and `bind`. [#43](https://github.com/unconed/mathbox/pull/43)

Expand Down
20 changes: 0 additions & 20 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,6 @@ const config = {
},
externals: {
three: "THREE",
"three/src/cameras/PerspectiveCamera.js": "THREE",
"three/src/constants.js": "THREE",
"three/src/core/BufferAttribute.js": "THREE",
"three/src/core/BufferGeometry.js": "THREE",
"three/src/core/Object3D.js": "THREE",
"three/src/geometries/PlaneGeometry.js": "THREE",
"three/src/materials/MeshBasicMaterial.js": "THREE",
"three/src/materials/RawShaderMaterial.js": "THREE",
"three/src/math/Color.js": "THREE",
"three/src/math/Euler.js": "THREE",
"three/src/math/Matrix3.js": "THREE",
"three/src/math/Matrix4.js": "THREE",
"three/src/math/Vector2.js": "THREE",
"three/src/math/Vector3.js": "THREE",
"three/src/math/Vector4.js": "THREE",
"three/src/math/Quaternion.js": "THREE",
"three/src/objects/Mesh.js": "THREE",
"three/src/renderers/WebGLRenderTarget.js": "THREE",
"three/src/scenes/Scene.js": "THREE",
"three/src/textures/Texture.js": "THREE",
},

// The output defines how and where we want the bundles. The special value
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"css-select": "^4.2.1",
"lodash": "^4.17.21",
"shadergraph": "^2.1.3",
"threestrap": "^0.5.0"
"threestrap": "^0.5.1"
},
"peerDependencies": {
"three": ">=0.118.0"
Expand Down
2 changes: 1 addition & 1 deletion src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as Shaders from "./shaders";
import * as Stage from "./stage";
import * as Util from "./util";

import { PerspectiveCamera } from "three/src/cameras/PerspectiveCamera.js";
import { PerspectiveCamera } from "three";

export class Context {
static initClass() {
Expand Down
3 changes: 1 addition & 2 deletions src/primitives/types/camera/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
*/

import * as UThree from "../../../util/three.js";
import { Euler } from "three/src/math/Euler.js";
import { Euler, Quaternion } from "three";
import { Primitive } from "../../primitive.js";
import { Quaternion } from "three/src/math/Quaternion.js";

export class Camera extends Primitive {
static initClass() {
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/types/draw/surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import * as UJS from "../../../util/js.js";
import { Color } from "three/src/math/Color.js";
import { Color } from "three";
import { Primitive } from "../../primitive.js";

export class Surface extends Primitive {
Expand Down
5 changes: 2 additions & 3 deletions src/primitives/types/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
import * as UGLSL from "../../util/glsl.js";
import * as UTicks from "../../util/ticks.js";

import { NormalBlending } from "three/src/constants.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { Vector3 } from "three/src/math/Vector3.js";
import { NormalBlending, Vector2, Vector3 } from "three";

/*

This is the general dumping ground for trait behavior.
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/types/text/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { FloatType, NearestFilter } from "three/src/constants.js";
import { FloatType, NearestFilter } from "three";
import { Operator } from "../operator/operator.js";

export class Format extends Operator {
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/types/text/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import * as UData from "../../../util/data.js";

import { FloatType, NearestFilter } from "three/src/constants.js";
import { FloatType, NearestFilter } from "three";
import { Buffer } from "../data/buffer.js";
import { Voxel } from "../data/voxel.js";

Expand Down
16 changes: 8 additions & 8 deletions src/primitives/types/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ import * as UJS from "../../util/js.js";

import {
ByteType,
Color,
FloatType,
IntType,
LinearFilter,
LinearMipMapLinearFilter,
LinearMipMapNearestFilter,
Matrix3,
Matrix4,
NearestFilter,
NearestMipMapLinearFilter,
NearestMipMapNearestFilter,
Quaternion,
ShortType,
UnsignedByteType,
UnsignedIntType,
UnsignedShortType,
} from "three/src/constants.js";
import { Color } from "three/src/math/Color.js";
import { Matrix3 } from "three/src/math/Matrix3.js";
import { Matrix4 } from "three/src/math/Matrix4.js";
import { Quaternion } from "three/src/math/Quaternion.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { Vector3 } from "three/src/math/Vector3.js";
import { Vector4 } from "three/src/math/Vector4.js";
Vector2,
Vector3,
Vector4,
} from "three";

// Property types
//
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/types/view/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as UAxis from "../../../util/axis.js";
import * as UThree from "../../../util/three.js";

import { Vector2 } from "three/src/math/Vector2.js";
import { Vector2 } from "three";
import { View } from "./view.js";

export class Polar extends View {
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/types/view/spherical.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as UAxis from "../../../util/axis.js";
import * as UThree from "../../../util/three.js";

import { Vector2 } from "three/src/math/Vector2.js";
import { Vector2 } from "three";
import { View } from "./view.js";

export class Spherical extends View {
Expand Down
2 changes: 1 addition & 1 deletion src/render/buffer/atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as UGLSL from "../../util/glsl.js";
import { BackedTexture } from "./texture/backedtexture.js";
import { DataTexture } from "./texture/datatexture.js";
import { Renderable } from "../renderable.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { Vector2 } from "three";

/*
* Dynamic sprite atlas
Expand Down
2 changes: 1 addition & 1 deletion src/render/buffer/databuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as UGLSL from "../../util/glsl.js";

import { Buffer } from "./buffer.js";
import { DataTexture } from "./texture/datatexture.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { Vector2 } from "three";

/*
* Data buffer on the GPU
Expand Down
2 changes: 1 addition & 1 deletion src/render/buffer/memo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { RGBAFormat } from "three/src/constants.js";
import { RGBAFormat } from "three";
import { RenderToTexture } from "./rendertotexture.js";

/*
Expand Down
3 changes: 1 addition & 2 deletions src/render/buffer/readback.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
import * as UData from "../../util/data.js";
import * as UGLSL from "../../util/glsl.js";

import { FloatType, UnsignedByteType } from "three/src/constants.js";
import { FloatType, UnsignedByteType, Vector4 } from "three";
import { Memo } from "./memo.js";
import { MemoScreen } from "../meshes/memoscreen.js";
import { Renderable } from "../renderable.js";
import { Vector4 } from "three/src/math/Vector4.js";

/*
* Readback up to 4D array of up to 4D data from GL
Expand Down
5 changes: 1 addition & 4 deletions src/render/buffer/rendertotexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

import * as UGLSL from "../../util/glsl.js";

import { PerspectiveCamera } from "three/src/cameras/PerspectiveCamera.js";
import { PerspectiveCamera, Scene, Vector2, Vector3 } from "three";
import { RenderTarget } from "./texture/rendertarget.js";
import { Renderable } from "../renderable.js";
import { Scene } from "three/src/scenes/Scene.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { Vector3 } from "three/src/math/Vector3.js";

/*
* Render-To-Texture with history
Expand Down
2 changes: 1 addition & 1 deletion src/render/buffer/textatlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { Atlas } from "./atlas.js";
import { UnsignedByteType } from "three/src/constants.js";
import { UnsignedByteType } from "three";

const SCRATCH_SIZE = 512 / 16;

Expand Down
5 changes: 2 additions & 3 deletions src/render/buffer/texture/datatexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import * as CONST from "three/src/constants.js";
import * as CONST from "three";
import * as UThree from "../../../util/three.js";

import { Texture } from "three/src/textures/Texture.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { Texture, Vector2 } from "three";

/*
Manually allocated GL texture for data streaming.
Expand Down
10 changes: 3 additions & 7 deletions src/render/buffer/texture/rendertarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ Provides easy access to past rendered frames
@reads[] and @write contain WebGLRenderTargets whose internal pointers are rotated automatically
*/

import {
NearestFilter,
RGBAFormat,
UnsignedByteType,
} from "three/src/constants.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { WebGLRenderTarget } from "three/src/renderers/WebGLRenderTarget.js";
import { NearestFilter, RGBAFormat, UnsignedByteType } from "three";
import { Vector2 } from "three";
import { WebGLRenderTarget } from "three";

export class RenderTarget {
constructor(gl, width, height, frames, options) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/arrowgeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { BufferAttribute } from "three";
import { ClipGeometry } from "./clipgeometry.js";

/*
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/clipgeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { Geometry } from "./geometry.js";
import { Vector4 } from "three/src/math/Vector4.js";
import { Vector4 } from "three";

// Instanced geometry that is clippable along 4 dimensions
export class ClipGeometry extends Geometry {
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/facegeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { BufferAttribute } from "three";
import { ClipGeometry } from "./clipgeometry.js";

/*
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { BufferGeometry } from "three/src/core/BufferGeometry.js";
import { BufferGeometry } from "three";

export class Geometry extends BufferGeometry {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/linegeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { BufferAttribute } from "three";
import { ClipGeometry } from "./clipgeometry.js";

/*
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/screengeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { SurfaceGeometry } from "./surfacegeometry.js";
import { Vector4 } from "three/src/math/Vector4.js";
import { Vector4 } from "three";

/*
Grid Surface in normalized screen space
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/spritegeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { BufferAttribute } from "three";
import { ClipGeometry } from "./clipgeometry.js";

/*
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/stripgeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { BufferAttribute } from "three";
import { ClipGeometry } from "./clipgeometry.js";

/*
Expand Down
2 changes: 1 addition & 1 deletion src/render/geometry/surfacegeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { BufferAttribute } from "three";
import { ClipGeometry } from "./clipgeometry.js";

/*
Expand Down
3 changes: 1 addition & 2 deletions src/render/meshes/arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/

import { DoubleSide, Mesh } from "three";
import { ArrowGeometry } from "../geometry/arrowgeometry.js";
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";

export class Arrow extends Base {
constructor(renderer, shaders, options) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/meshes/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import * as UGLSL from "../../util/glsl.js";

import { RawShaderMaterial } from "three/src/materials/RawShaderMaterial.js";
import { RawShaderMaterial } from "three";
import { Renderable } from "../renderable.js";

export class Base extends Renderable {
Expand Down
Loading