Skip to content
Open
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
74,717 changes: 74,717 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions dist/src/components/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export { default as collideEntities } from "./collideEntities";
export { default as collideTerrain } from "./collideTerrain";
export { default as fadeOnZoom } from "./fadeOnZoom";
export { default as followsEntity } from "./followsEntity";
export { default as mesh } from "./mesh";
export { default as movement } from "./movement";
export { default as physics } from "./physics";
export { default as position } from "./position";
export { default as receivesInputs } from "./receivesInputs";
export { default as shadow } from "./shadow";
export { default as smoothCamera } from "./smoothCamera";
2 changes: 0 additions & 2 deletions dist/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export class Engine extends EventEmitter {
* ```
*/
constructor(opts?: {});
/** Version string, e.g. `"0.25.4"` */
version: string;
/** @internal */
_paused: boolean;
/** @internal */
Expand Down
2 changes: 1 addition & 1 deletion docs/API/assets/search.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions docs/API/classes/noa.Engine.html

Large diffs are not rendered by default.

554 changes: 547 additions & 7 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
"name": "noa-engine",
"version": "0.31.0",
"description": "Experimental voxel game engine",
"main": "src/index.js",
"main": "dist/index.js",
"typings": "dist/src/index.d.ts",
"files": [
"/src",
"/dist"
],
"scripts": {
"build": "npm run types; npm run docs",
"build": "rimraf dist; rollup -c rollup.config.js; npm run types; npm run docs; ",
"types": "tsc",
"docs": "typedoc"
},
"author": "Andy Hall (https://fenomas.com)",
"license": "MIT",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/fenomas/noa.git"
Expand All @@ -33,14 +34,20 @@
"micro-game-shell": "^0.3.0",
"ndarray": "^1.0.19",
"voxel-aabb-sweep": "^0.5.0",
"voxel-physics-engine": "^0.11.1"
"voxel-physics-engine": "^0.13.0"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the main change. it they removed all the require statements in this latest version (by they, I mean the creator fo voxel-physics-engine, which is the same creator of noa)

},
"peerDependencies": {
"@babylonjs/core": "5.0.0-alpha.48"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.3.3",
"eslint": "^7.26.0",
"js-beautify": "^1.13.13",
"rimraf": "^3.0.2",
"rollup": "^2.77.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"typedoc": "^0.22.6",
"typescript": "^4.4.3"
},
Expand Down
16 changes: 16 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import typescript from "@rollup/plugin-typescript"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import commonjs from "rollup-plugin-commonjs"
import peerDepsExternal from "rollup-plugin-peer-deps-external"

import { defineConfig } from "rollup"

export default defineConfig({
input: "./src/index.js",
treeshake: true,
output: {
dir: "dist",
sourcemap: true,
},
plugins: [nodeResolve(), typescript(), commonjs()],
})
3 changes: 1 addition & 2 deletions src/components/collideEntities.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

var boxIntersect = require('box-intersect')
import boxIntersect from 'box-intersect'



Expand Down
11 changes: 11 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export {default as collideEntities} from "./collideEntities"
export {default as collideTerrain} from "./collideTerrain"
export {default as fadeOnZoom} from "./fadeOnZoom"
export {default as followsEntity} from "./followsEntity"
export {default as mesh} from "./mesh"
export {default as movement} from "./movement"
export {default as physics} from "./physics"
export {default as position} from "./position"
export {default as receivesInputs} from "./receivesInputs"
export {default as shadow} from "./shadow"
export {default as smoothCamera} from "./smoothCamera"
11 changes: 2 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import { World } from './lib/world'
import { locationHasher } from './lib/util'


import packageJSON from '../package.json'
var version = packageJSON.version



// profile every N ticks/renders
var PROFILE = 0
var PROFILE_RENDER = 0
Expand Down Expand Up @@ -103,10 +98,9 @@ export class Engine extends EventEmitter {
opts = Object.assign({}, defaultOptions, opts)

/** Version string, e.g. `"0.25.4"` */
this.version = version
if (!opts.silent) {
var debugstr = (opts.debug) ? ' (debug)' : ''
console.log(`noa-engine v${this.version}${debugstr}`)
console.log(`noa-engine ${debugstr}`)
}

/** @internal */
Expand Down Expand Up @@ -713,8 +707,7 @@ function deprecateStuff(noa) {




var makeProfileHook = require('./lib/util').makeProfileHook
import { makeProfileHook } from './lib/util'
var profile_hook = (PROFILE > 0) ?
makeProfileHook(PROFILE, 'tick ') : () => { }
var profile_hook_render = (PROFILE_RENDER > 0) ?
Expand Down
3 changes: 1 addition & 2 deletions src/lib/chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*/

import { LocationQueue } from './util'

var ndarray = require('ndarray')
import ndarray from 'ndarray'

export default Chunk

Expand Down
12 changes: 4 additions & 8 deletions src/lib/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import vec3 from 'gl-vec3'
import { updatePositionExtents } from '../components/position'
import { setPhysicsFromPosition } from '../components/physics'

import * as components from "../components"


var defaultOptions = {
Expand Down Expand Up @@ -426,14 +427,9 @@ function extentsOverlap(extA, extB) {
// Bundler magic to import everything in the ../components directory
// each component module exports a default function: (noa) => compDefinition
function importLocalComponents(ents, args, createCompFn) {
//@ts-expect-error
var reqContext = require.context('../components/', false, /\.js$/)
for (var name of reqContext.keys()) {
// convert name ('./foo.js') to bare name ('foo')
var bareName = /\.\/(.*)\.js/.exec(name)[1]
var arg = args[bareName] || undefined
var compFn = reqContext(name)
if (compFn.default) compFn = compFn.default
for (var name of Object.keys(components)) {
var arg = args[name] || undefined
var compFn = components[name]
var compDef = compFn(ents.noa, arg)
var comp = createCompFn(compDef)
ents.names[compDef.name] = comp
Expand Down
3 changes: 2 additions & 1 deletion src/lib/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/


var glvec3 = require('gl-vec3')
import glvec3 from 'gl-vec3'

import { SceneOctreeManager } from './sceneOctreeManager'

Expand Down Expand Up @@ -114,6 +114,7 @@ function initScene(self, canvas, opts) {
// init internal properties
self._engine = new Engine(canvas, opts.antiAlias, {
preserveDrawingBuffer: opts.preserveDrawingBuffer,
disableWebGL2Support: true
})
self._scene = new Scene(self._engine)
var scene = self._scene
Expand Down