@leonardorick/three
v1.0.78
Published
Utils Three.js function from Leonardo Rick
Downloads
38
Readme
lthree
Javascript utility functions for handling three.js stuff
usage
`pnpm i @leonardorick/three`
on plain javascript
import lthree from './node_modules/@leonardorick/three/index.js';
on a modern JS application working with bundlers
import lthree from '@leoanrdorick/three';
publish
npm run deploy
add new functions
If you are going to add a new "module" (file) make sure to keep the same structure present on the project. The following three folders should have (almost) the same structure:
src/
Where the.js
file is located and the function is actually implemented. This function should be imported insidesrc/index.js
, which is the only file that is not repeated on the other folders. This file abastracts the complexity of the actualindex.js
outside thesrc
folder that import stuff from './dist' and we don't want to keep updating it everytime.Make sure to add some JSDocs one each function explaining it usage
tests/
Any function should have at least one test for it implementation. Preferably the module will have more than one test per function implement to contemplate multiple scenariostypes/
The signature of the exported classes/functions should be present ontypes/
as a.d.ts
file. This file should also be imported on thetypes/index.d.ts
so all types of the exported package members can be properly infered by IDE's
Try to make the functions inside each module ordered alphabetically as much as possible!
Code patterns
Optional parameters: Usually optional parameters are the last param of the function and are inside a object with default values.
funciton something(a, {
opt1 = true,
opt2 = null,
opt3 = 5,
} = {})
internal imports: If some module imports another one internally it needs to import it with the extension. This allows the builded version to work as expected
import { hypotenuse, round } from './math.js'; // right
//...
import { hypotenuse, round } from './math'; // wrong