diff --git a/geometry.js b/common/geometry.js similarity index 100% rename from geometry.js rename to common/geometry.js diff --git a/gl.js b/common/gl.js similarity index 100% rename from gl.js rename to common/gl.js diff --git a/memoize.js b/common/memoize.js similarity index 100% rename from memoize.js rename to common/memoize.js diff --git a/common/package.json b/common/package.json new file mode 100644 index 0000000..c51b4f9 --- /dev/null +++ b/common/package.json @@ -0,0 +1,8 @@ +{ + "name": "wmc-common", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "esbuild": "^0.14.2" + } +} diff --git a/se3.js b/common/se3.js similarity index 100% rename from se3.js rename to common/se3.js diff --git a/skycraft/chunk.ts b/skycraft/chunk.ts index 0b41bb5..318dc56 100644 --- a/skycraft/chunk.ts +++ b/skycraft/chunk.ts @@ -1,6 +1,6 @@ -import { makeFace } from '../geometry'; +import { makeFace } from 'wmc-common/geometry'; import * as linalg from './linalg'; -import {memoize} from '../memoize'; +import {memoize} from 'wmc-common/memoize'; type direction = ('-x' | '+x' | '-y' | '+y' | '-z' | '+z'); @@ -310,4 +310,4 @@ export function getBodyGeometry(seed: number) { .map(chunk => [...makeChunkFaces(chunk)]); return faces.reduce((a, b) => a.concat(b)); -} \ No newline at end of file +} diff --git a/skycraft/draw.ts b/skycraft/draw.ts index bef27c4..786a265 100644 --- a/skycraft/draw.ts +++ b/skycraft/draw.ts @@ -1,7 +1,7 @@ -import {makeBufferFromFaces } from '../geometry'; -import { loadTexture, makeProgram } from '../gl'; +import {makeBufferFromFaces } from 'wmc-common/geometry'; +import { loadTexture, makeProgram } from 'wmc-common/gl'; import * as linalg from './linalg'; -import * as se3 from '../se3'; +import * as se3 from 'wmc-common/se3'; import { makeOrbitObject } from './orbit'; const VSHADER = ` diff --git a/skycraft/index.ts b/skycraft/index.ts index 9ad907a..0ed9515 100644 --- a/skycraft/index.ts +++ b/skycraft/index.ts @@ -1,8 +1,8 @@ -import { makeFace } from '../geometry'; +import { makeFace } from 'wmc-common/geometry'; import * as linalg from './linalg'; import { loadObjModel } from './obj'; -import * as se3 from '../se3'; +import * as se3 from 'wmc-common/se3'; import { computeOrbit, findSoi, getCartesianState, updateBodyPhysics } from './orbit'; import { getBodyGeometry } from './chunk'; import { draw, getOrbitDrawContext, initWorldGl } from './draw'; @@ -406,4 +406,4 @@ async function main() { requestAnimationFrame(time => tick(time, context)); } -window.onload = main; \ No newline at end of file +window.onload = main; diff --git a/skycraft/orbit.ts b/skycraft/orbit.ts index 5d85620..dea4426 100644 --- a/skycraft/orbit.ts +++ b/skycraft/orbit.ts @@ -1,4 +1,4 @@ -import * as se3 from '../se3'; +import * as se3 from 'wmc-common/se3'; import * as linalg from './linalg'; import {Vec3} from './linalg'; @@ -277,4 +277,4 @@ export function makeOrbitObject(gl: WebGLRenderingContext, glContext: any, orbit position, glContext, }; -} \ No newline at end of file +} diff --git a/skycraft/package.json b/skycraft/package.json index f387703..859d92e 100644 --- a/skycraft/package.json +++ b/skycraft/package.json @@ -4,11 +4,12 @@ "main": "index.ts", "license": "MIT", "dependencies": { - "esbuild": "^0.14.2" + "esbuild": "^0.14.2", + "wmc-common": "link:../common" }, "scripts": { - "watch": "esbuild --outfile=app.js index.ts --bundle --sourcemap=inline --watch", - "serve": "esbuild --outfile=app.js index.ts --bundle --sourcemap=inline --servedir=.", + "watch": "esbuild --outfile=static/app.js index.ts --bundle --sourcemap=inline --watch", + "serve": "esbuild --outfile=static/app.js index.ts --bundle --sourcemap=inline --servedir=static", "build": "esbuild --outfile=app.js index.ts --bundle --minify" } } diff --git a/skycraft/quat.ts b/skycraft/quat.ts index 6592285..3dc2417 100644 --- a/skycraft/quat.ts +++ b/skycraft/quat.ts @@ -1,5 +1,5 @@ import {Mat4} from './linalg'; -import * as se3 from '../se3'; +import * as se3 from 'wmc-common/se3'; export interface Quat { x: number, @@ -121,4 +121,4 @@ export function scale(q: Quat, a: number): Quat { z: a * q.z, w: a * q.w, }; -} \ No newline at end of file +} diff --git a/skycraft/index.html b/skycraft/static/index.html similarity index 100% rename from skycraft/index.html rename to skycraft/static/index.html diff --git a/skycraft/spaceship.obj b/skycraft/static/spaceship.obj similarity index 100% rename from skycraft/spaceship.obj rename to skycraft/static/spaceship.obj diff --git a/skycraft/static/texture.png b/skycraft/static/texture.png new file mode 100644 index 0000000..262de73 Binary files /dev/null and b/skycraft/static/texture.png differ diff --git a/skycraft/texture.png b/skycraft/texture.png deleted file mode 120000 index 71e5e58..0000000 --- a/skycraft/texture.png +++ /dev/null @@ -1 +0,0 @@ -../texture.png \ No newline at end of file diff --git a/skycraft/yarn.lock b/skycraft/yarn.lock index 646c141..a53031a 100644 --- a/skycraft/yarn.lock +++ b/skycraft/yarn.lock @@ -44,7 +44,7 @@ esbuild-linux-32@0.14.54: esbuild-linux-64@0.14.54: version "0.14.54" - resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz#de5fdba1c95666cf72369f52b40b03be71226652" + resolved "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz" integrity sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg== esbuild-linux-arm64@0.14.54: @@ -109,7 +109,7 @@ esbuild-windows-arm64@0.14.54: esbuild@^0.14.2: version "0.14.54" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.54.tgz#8b44dcf2b0f1a66fc22459943dccf477535e9aa2" + resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.14.54.tgz" integrity sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA== optionalDependencies: "@esbuild/linux-loong64" "0.14.54" @@ -133,3 +133,7 @@ esbuild@^0.14.2: esbuild-windows-32 "0.14.54" esbuild-windows-64 "0.14.54" esbuild-windows-arm64 "0.14.54" + +"wmc-common@link:../common": + version "0.0.0" + uid ""