const geometry = new THREE.BoxLineGeometry();
const material = new THREE.LineBasicMaterial( { color: 0x00ff00 } );
const lines = new THREE.LineSegments( geometry, material );
scene.add( lines );
Should be this:
const geometry = new BoxLineGeometry();
const material = new THREE.LineBasicMaterial( { color: 0x00ff00 } );
const lines = new THREE.LineSegments( geometry, material );
scene.add( lines );
As THREE.BoxLineGeometry is not a constructor.
I know it’s a minor typo, just thought I’d point it out. Don’t know if Site Feedback is the right place for this kind of thing. Sorry if not, but I don’t have GitHub.
Is there something automagical that appends imported addons to the three name space? I only ever imported stuff with build tools. The reason im asking is maybe other examples have this too, or if there is indeed somethingn that will put an addon to THREE it might not be doing it here.
import { BoxLineGeometry } from 'three/addons/geometries/BoxLineGeometry.js';
not that I’m aware of, three is imported as import * as THREE from "three"… eg the THREE namespace is assigned at import (it’s not an assignable class per se)… (this could be any arbitrary namespace for example import * as EggsBenidorm from "three"… const v3 = new EggsBenidorm.Vector3() ), I’m not sure how an external module would be assigned to the three module in this case or if that’s even possible
Yeah, looks like three double downed on these jsdoc comment thingies.
Essentially there is a comment in the source file that just gets copied into the docs file. It also seems to have quietly switched to typescript over time via the same comments. Kinda clever because you kinda get to modify the docs in the same file, but theres nothing validating it hence this error.
as far as I’m aware the lexicon would follow the same rules in an import map as with build tools, addons (where BoxLineGeometry is exported from) would still be an external resource to the core three module…
yeah jsdoc is neat and really useful! I’m not sure it’s as thorough as ts types but I think js has adopted types by those same comments, putting the following comments in a class will allow you to see a constructors parameter types when hovering an instantiated class in your IDE…
class TorusGeometry extends BufferGeometry {
/**
* Constructs a new torus geometry.
*
* @param {number} [radius=1] - Radius of the torus, from the center of the torus to the center of the tube.
* @param {number} [tube=0.4] - Radius of the tube. Must be smaller than `radius`.
* @param {number} [radialSegments=12] - The number of radial segments.
* @param {number} [tubularSegments=48] - The number of tubular segments.
* @param {number} [arc=Math.PI*2] - Central angle in radians.
* @param {number} [thetaStart=0] - Start of the tubular sweep in radians.
* @param {number} [thetaLength=Math.PI*2] - Length of the tubular sweep in radians.
*/
constructor( radius = 1, tube = 0.4, radialSegments = 12, tubularSegments = 48, arc = Math.PI * 2, thetaStart = 0, thetaLength = Math.PI * 2 ) {
I prefer typescript. But if I understood correctly JSDoc is just a more verbose way to write typescript. You don’t need a build tool but I don’t know why anyone would not want one.
I don’t mind ts if a project requires it, I prefer js and using it in a compiler environment the js comment syntax reduces having to separately manage writing types, comments and documentation, the docs are built on compile automatically from the comments, the comments can be written as self explanatory comment blocks and thirdly serve as “type” definitions for the classes and functions they are attributed to…