Skip to content

Commit

Permalink
Updates **many** jsdoc comments to improve generated docs
Browse files Browse the repository at this point in the history
Renames several internals to public:
  `rendering._engine` to `engine`
  `rendering._camera` to `camera`
  `rendering._scene` to `scene`
  `rendering._light` to `light`
  • Loading branch information
fenomas committed May 1, 2023
1 parent 33b833d commit e1ad62f
Show file tree
Hide file tree
Showing 19 changed files with 133 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
"es6": true,
},
"parserOptions": {
"ecmaVersion": 10,
"ecmaVersion": 13,
"sourceType": "module",
},
"rules": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"eslint": "^8.3.0",
"js-beautify": "^1.14.0",
"typedoc": "^0.24.6",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "^5.0.4"
},
"keywords": [
Expand Down
4 changes: 0 additions & 4 deletions src/components/movement.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @module
* @internal
*/

import vec3 from 'gl-vec3'

Expand Down
27 changes: 17 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/** @module noa */

/*!
* noa: an experimental voxel game engine.
Expand All @@ -18,8 +17,8 @@ import { Inputs } from './lib/inputs'
import { Container } from './lib/container'
import { Camera } from './lib/camera'
import { Entities } from './lib/entities'
import ObjectMesher from './lib/objectMesher'
import TerrainMesher from './lib/terrainMesher'
import { ObjectMesher } from './lib/objectMesher'
import { TerrainMesher } from './lib/terrainMesher'
import { Registry } from './lib/registry'
import { Rendering } from './lib/rendering'
import { Physics } from './lib/physics'
Expand Down Expand Up @@ -73,12 +72,6 @@ var defaultOptions = {
* child modules ({@link Rendering}, {@link Container}, etc).
* See docs for each module for their options.
*
* @emits tick(dt)
* @emits beforeRender(dt)
* @emits afterRender(dt)
* @emits targetBlockChanged(blockDesc)
* @emits addingTerrainMesh(mesh)
* @emits removingTerrainMesh(mesh)
*/

export class Engine extends EventEmitter {
Expand All @@ -105,6 +98,20 @@ export class Engine extends EventEmitter {
* originRebaseDistance: 25,
* }
* ```
*
* **Events:**
* + `tick => (dt)`
* Tick update, `dt` is (fixed) tick duration in ms
* + `beforeRender => (dt)`
* `dt` is the time (in ms) since the most recent tick
* + `afterRender => (dt)`
* `dt` is the time (in ms) since the most recent tick
* + `targetBlockChanged => (blockInfo)`
* Emitted each time the user's targeted world block changes
* + `addingTerrainMesh => (mesh)`
* Alerts client about a terrain mesh being added to the scene
* + `removingTerrainMesh => (mesh)`
* Alerts client before a terrain mesh is removed.
*/
constructor(opts = {}) {
super()
Expand Down Expand Up @@ -313,7 +320,7 @@ export class Engine extends EventEmitter {
win.noa = this
win.vec3 = vec3
win.ndarray = ndarray
win.scene = this.rendering._scene
win.scene = this.rendering.scene
}

// add hooks to throw helpful errors when using deprecated methods
Expand Down
6 changes: 1 addition & 5 deletions src/lib/camera.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* The Camera class is found at [[Camera | `noa.camera`]].
* @module noa.camera
*/

import vec3 from 'gl-vec3'
import aabb from 'aabb-3d'
Expand Down Expand Up @@ -36,7 +32,7 @@ var originVector = vec3.create()
* mouse sensitivity, and so on.
*
* This module uses the following default options (from the options
* object passed to the [[Engine]]):
* object passed to the {@link Engine}):
* ```js
* var defaults = {
* inverseX: false,
Expand Down
5 changes: 1 addition & 4 deletions src/lib/chunk.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @module
* @internal
*/

import { LocationQueue } from './util'
import ndarray from 'ndarray'
Expand Down Expand Up @@ -73,6 +69,7 @@ export function Chunk(noa, requestID, ci, cj, ck, size, dataArray, fillVoxelID =
this._timesMeshed = 0

// location queue of voxels in this chunk with block handlers (assume it's rare)
/** @internal */
this._blockHandlerLocs = new LocationQueue()

// passes through voxel contents, calling block handlers etc.
Expand Down
14 changes: 7 additions & 7 deletions src/lib/container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* The Container class is found at [[Container | `noa.container`]].
* @module noa.container
*/

import { EventEmitter } from 'events'
import { MicroGameShell } from 'micro-game-shell'
Expand All @@ -16,9 +12,13 @@ import { MicroGameShell } from 'micro-game-shell'
*
* This module wraps `micro-game-shell`, which does most of the implementation.
*
* @emits DOMready
* @emits gainedPointerLock
* @emits lostPointerLock
* **Events**
* + `DOMready => ()`
* Relays the browser DOMready event, after noa does some initialization
* + `gainedPointerLock => ()`
* Fires when the game container gains pointerlock.
* + `lostPointerLock => ()`
* Fires when the game container loses pointerlock.
*/

export class Container extends EventEmitter {
Expand Down
6 changes: 1 addition & 5 deletions src/lib/entities.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* The ECS manager, found at [[Entities | `noa.entities`]] or [[Entities | `noa.ents`]].
* @module noa.entities
*/

import ECS from 'ent-comp'
import vec3 from 'gl-vec3'
Expand Down Expand Up @@ -40,7 +36,7 @@ var defaultOptions = {
* folder for examples.
*
* This module uses the following default options (from the options
* object passed to the [[Engine]]):
* object passed to the {@link Engine}):
*
* ```js
* var defaults = {
Expand Down
7 changes: 1 addition & 6 deletions src/lib/inputs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* The Inputs class is found at [[Inputs | `noa.inputs`]].
* @module noa.inputs
*/


import { GameInputs } from 'game-inputs'

Expand Down Expand Up @@ -32,7 +27,7 @@ var defaultBindings = {
* for full docs.
*
* This module uses the following default options (from the options
* object passed to the [[Engine]]):
* object passed to the {@link Engine}):
*
* ```js
* defaultBindings: {
Expand Down
14 changes: 6 additions & 8 deletions src/lib/objectMesher.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/**
* @module
* @internal exclude this file from API docs
*/

import { TransformNode } from '@babylonjs/core/Meshes/transformNode'
import { makeProfileHook } from './util'
import '@babylonjs/core/Meshes/thinInstanceMesh'

export default ObjectMesher

var PROFILE = 0

Expand All @@ -26,11 +21,14 @@ var PROFILE = 0
*/


/** @param {import('../index').Engine} noa*/
function ObjectMesher(noa) {
/**
* @internal
* @param {import('../index').Engine} noa
*/
export function ObjectMesher(noa) {

// transform node for all instance meshes to be parented to
this.rootNode = new TransformNode('objectMeshRoot', noa.rendering._scene)
this.rootNode = new TransformNode('objectMeshRoot', noa.rendering.scene)

// tracking rebase amount inside matrix data
var rebaseOffset = [0, 0, 0]
Expand Down
7 changes: 1 addition & 6 deletions src/lib/physics.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* The Physics class is found at [[Physics | `noa.physics`]].
* @module noa.physics
*/


import { Physics as VoxelPhysics } from 'voxel-physics-engine'

Expand All @@ -23,7 +18,7 @@ var defaultOptions = {
* for full docs.
*
* This module uses the following default options (from the options
* object passed to the [[Engine]]):
* object passed to the {@link Engine}):
*
* ```js
* {
Expand Down
9 changes: 3 additions & 6 deletions src/lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* The Registry class is found at [[Registry | `noa.registry`]].
* @module noa.registry
*/


var defaults = {
Expand All @@ -20,7 +16,7 @@ var MAX_BLOCK_ID = (1 << 16) - 1
* materials, properties, and events.
*
* This module uses the following default options (from the options
* object passed to the [[Engine]]):
* object passed to the {@link Engine}):
*
* ```js
* var defaults = {
Expand Down Expand Up @@ -178,7 +174,7 @@ export class Registry {

this.registerMaterial = function (name = '?', options = null) {
// catch calls to earlier signature
if (Array.isArray(options) || arguments[2]) {
if (Array.isArray(options)) {
throw 'This API changed signatures in v0.33, please use: `noa.registry.registerMaterial("name", optionsObj)`'
}

Expand Down Expand Up @@ -266,6 +262,7 @@ export class Registry {
/**
* Given a texture URL, does any material using that
* texture need alpha?
* @internal
* @returns {boolean}
*/
this._textureNeedsAlpha = function (tex = '') {
Expand Down
Loading

0 comments on commit e1ad62f

Please sign in to comment.