Three.js: Missing TrackballControls export in NPM package

Created on 29 Apr 2020  路  3Comments  路  Source: mrdoob/three.js

Hello!

Your library/framework is obviously amazing. I believe you are accidentally not exporting the controls folder right now with your NPM package.

It means that actually the only way to access commonly used library members such as TrackballControls is like so: https://github.com/vasturiano/three-render-objects/pull/5

Perhaps intentional but wanted to point out just in case.

(here's the Three.d.ts)

export * from './polyfills';
export * from './renderers/WebGLMultisampleRenderTarget';
export * from './renderers/WebGLCubeRenderTarget';
export * from './renderers/WebGLRenderTarget';
export * from './renderers/WebGLRenderer';
export * from './renderers/shaders/ShaderLib';
export * from './renderers/shaders/UniformsLib';
export * from './renderers/shaders/UniformsUtils';
export * from './renderers/shaders/ShaderChunk';
export * from './scenes/FogExp2';
export * from './scenes/Fog';
export * from './scenes/Scene';
export * from './objects/Sprite';
export * from './objects/LOD';
export * from './objects/InstancedMesh';
export * from './objects/SkinnedMesh';
export * from './objects/Skeleton';
export * from './objects/Bone';
export * from './objects/Mesh';
export * from './objects/LineSegments';
export * from './objects/LineLoop';
export * from './objects/Line';
export * from './objects/Points';
export * from './objects/Group';
export * from './textures/VideoTexture';
export * from './textures/DataTexture';
export * from './textures/DataTexture3D';
export * from './textures/CompressedTexture';
export * from './textures/CubeTexture';
export * from './textures/CanvasTexture';
export * from './textures/DepthTexture';
export * from './textures/Texture';
export * from './geometries/Geometries';
export * from './materials/Materials';
export * from './loaders/AnimationLoader';
export * from './loaders/CompressedTextureLoader';
export * from './loaders/DataTextureLoader';
export * from './loaders/CubeTextureLoader';
export * from './loaders/TextureLoader';
export * from './loaders/ObjectLoader';
export * from './loaders/MaterialLoader';
export * from './loaders/BufferGeometryLoader';
export * from './loaders/LoadingManager';
export * from './loaders/ImageLoader';
export * from './loaders/ImageBitmapLoader';
export * from './loaders/FontLoader';
export * from './loaders/FileLoader';
export * from './loaders/Loader';
export * from './loaders/LoaderUtils';
export * from './loaders/Cache';
export * from './loaders/AudioLoader';
export * from './lights/SpotLightShadow';
export * from './lights/SpotLight';
export * from './lights/PointLight';
export * from './lights/RectAreaLight';
export * from './lights/HemisphereLight';
export * from './lights/DirectionalLightShadow';
export * from './lights/DirectionalLight';
export * from './lights/AmbientLight';
export * from './lights/LightShadow';
export * from './lights/Light';
export * from './lights/AmbientLightProbe';
export * from './lights/HemisphereLightProbe';
export * from './lights/LightProbe';
export * from './cameras/StereoCamera';
export * from './cameras/PerspectiveCamera';
export * from './cameras/OrthographicCamera';
export * from './cameras/CubeCamera';
export * from './cameras/ArrayCamera';
export * from './cameras/Camera';
export * from './audio/AudioListener';
export * from './audio/PositionalAudio';
export * from './audio/AudioContext';
export * from './audio/AudioAnalyser';
export * from './audio/Audio';
export * from './animation/tracks/VectorKeyframeTrack';
export * from './animation/tracks/StringKeyframeTrack';
export * from './animation/tracks/QuaternionKeyframeTrack';
export * from './animation/tracks/NumberKeyframeTrack';
export * from './animation/tracks/ColorKeyframeTrack';
export * from './animation/tracks/BooleanKeyframeTrack';
export * from './animation/PropertyMixer';
export * from './animation/PropertyBinding';
export * from './animation/KeyframeTrack';
export * from './animation/AnimationUtils';
export * from './animation/AnimationObjectGroup';
export * from './animation/AnimationMixer';
export * from './animation/AnimationClip';
export * from './animation/AnimationAction';
export * from './core/Uniform';
export * from './core/InstancedBufferGeometry';
export * from './core/BufferGeometry';
export * from './core/Geometry';
export * from './core/InterleavedBufferAttribute';
export * from './core/InstancedInterleavedBuffer';
export * from './core/InterleavedBuffer';
export * from './core/InstancedBufferAttribute';
export * from './core/BufferAttribute';
export * from './core/Face3';
export * from './core/Object3D';
export * from './core/Raycaster';
export * from './core/Layers';
export * from './core/EventDispatcher';
export * from './core/DirectGeometry';
export * from './core/Clock';
export * from './math/interpolants/QuaternionLinearInterpolant';
export * from './math/interpolants/LinearInterpolant';
export * from './math/interpolants/DiscreteInterpolant';
export * from './math/interpolants/CubicInterpolant';
export * from './math/Interpolant';
export * from './math/Triangle';
export * from './math/MathUtils';
export * from './math/Spherical';
export * from './math/Cylindrical';
export * from './math/Plane';
export * from './math/Frustum';
export * from './math/Sphere';
export * from './math/Ray';
export * from './math/Matrix4';
export * from './math/Matrix3';
export * from './math/Box3';
export * from './math/Box2';
export * from './math/Line3';
export * from './math/Euler';
export * from './math/Vector4';
export * from './math/Vector3';
export * from './math/Vector2';
export * from './math/Quaternion';
export * from './math/Color';
export * from './math/SphericalHarmonics3';
export * from './extras/objects/ImmediateRenderObject';
export * from './helpers/SpotLightHelper';
export * from './helpers/SkeletonHelper';
export * from './helpers/PointLightHelper';
export * from './helpers/HemisphereLightHelper';
export * from './helpers/GridHelper';
export * from './helpers/PolarGridHelper';
export * from './helpers/DirectionalLightHelper';
export * from './helpers/CameraHelper';
export * from './helpers/BoxHelper';
export * from './helpers/Box3Helper';
export * from './helpers/PlaneHelper';
export * from './helpers/ArrowHelper';
export * from './helpers/AxesHelper';
export * from './extras/curves/Curves';
export * from './extras/core/Shape';
export * from './extras/core/Path';
export * from './extras/core/ShapePath';
export * from './extras/core/Font';
export * from './extras/core/CurvePath';
export * from './extras/core/Curve';
export * from './extras/ImageUtils';
export * from './extras/ShapeUtils';
export * from './extras/PMREMGenerator';
export * from './renderers/webgl/WebGLBufferRenderer';
export * from './renderers/webgl/WebGLCapabilities';
export * from './renderers/webgl/WebGLClipping';
export * from './renderers/webgl/WebGLExtensions';
export * from './renderers/webgl/WebGLGeometries';
export * from './renderers/webgl/WebGLIndexedBufferRenderer';
export * from './renderers/webgl/WebGLInfo';
export * from './renderers/webgl/WebGLLights';
export * from './renderers/webgl/WebGLObjects';
export * from './renderers/webgl/WebGLProgram';
export * from './renderers/webgl/WebGLPrograms';
export * from './renderers/webgl/WebGLProperties';
export * from './renderers/webgl/WebGLRenderLists';
export * from './renderers/webgl/WebGLShader';
export * from './renderers/webgl/WebGLShadowMap';
export * from './renderers/webgl/WebGLState';
export * from './renderers/webgl/WebGLTextures';
export * from './renderers/webgl/WebGLUniforms';
export * from './constants';
export * from './Three.Legacy';

export as namespace THREE;

Documentation

Most helpful comment

okay, you guys are obviously the ones making an amazing 3D library, not me haha.

With that caveat and due respect I will say given that the Examples section in the API docs could perhaps better be named Extensions since it looks like they're optional (and in some cases very common) library code, would make it obvious you're supposed to import from there:
https://threejs.org/docs/#examples/en/controls/TrackballControls.mouseButtons

It's also pretty confusing because there's a separate Examples heading which actually shows example usages of Three.js (which is where I assumed this referenced initially):
https://threejs.org/examples/#webgl_animation_cloth

I know naming things is hard and switching names is annoying

All 3 comments

Only files in the src/ directory are parts of the core three.js library. TrackballControls (and various other files under examples/jsm/* or examples/js/* are included in the NPM bundle, but must be imported explicitly from their own directories to be available in your build. For example:

npm install --save three
import { Scene, WebGLRenderer } from 'three';
import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls.js';

I'd like to make this clearer in the docs, which I think https://github.com/mrdoob/three.js/pull/18778 would help with.

okay, you guys are obviously the ones making an amazing 3D library, not me haha.

With that caveat and due respect I will say given that the Examples section in the API docs could perhaps better be named Extensions since it looks like they're optional (and in some cases very common) library code, would make it obvious you're supposed to import from there:
https://threejs.org/docs/#examples/en/controls/TrackballControls.mouseButtons

It's also pretty confusing because there's a separate Examples heading which actually shows example usages of Three.js (which is where I assumed this referenced initially):
https://threejs.org/examples/#webgl_animation_cloth

I know naming things is hard and switching names is annoying

@sirrodgepodge this has been a thought of mine too however I have yet to put in the time and energy into pushing for these kinds of changes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

makc picture makc  路  3Comments

scrubs picture scrubs  路  3Comments

boyravikumar picture boyravikumar  路  3Comments

seep picture seep  路  3Comments

yqrashawn picture yqrashawn  路  3Comments