Compare commits
No commits in common. "ee7f5e9595c06edb52a5d8fd5577613c41e52d62" and "9bb162e7d539374d45781b90ba713a9859c1e719" have entirely different histories.
ee7f5e9595
...
9bb162e7d5
24
Dockerfile
24
Dockerfile
@ -1,24 +0,0 @@
|
||||
FROM node:23-alpine as skycraft-deps
|
||||
|
||||
WORKDIR /workspace/skycraft
|
||||
ADD ./skycraft/package.json ./
|
||||
ADD ./skycraft/yarn.lock ./
|
||||
RUN yarn install
|
||||
|
||||
|
||||
FROM skycraft-deps as skycraft-build
|
||||
|
||||
ADD . /workspace
|
||||
RUN yarn build
|
||||
|
||||
|
||||
FROM skycraft-deps as skycraft-dev
|
||||
|
||||
ENTRYPOINT ["yarn"]
|
||||
CMD ["run", "serve"]
|
||||
|
||||
|
||||
FROM scratch as skycraft-export
|
||||
|
||||
COPY --from=skycraft-build /workspace/skycraft/app.js /
|
||||
COPY --from=skycraft-build /workspace/skycraft/static/* /
|
31
Makefile
31
Makefile
@ -1,31 +0,0 @@
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
skycraft-dev-image := skycraft-dev
|
||||
|
||||
.PHONY: skycraft
|
||||
skycraft: ## build skycraft
|
||||
docker build \
|
||||
--output=out/skycraft \
|
||||
--target=skycraft-export \
|
||||
.
|
||||
|
||||
.PHONY: skycraft-dev-image
|
||||
skycraft-dev-image:
|
||||
docker build \
|
||||
-t $(skycraft-dev-image) \
|
||||
--target=skycraft-dev \
|
||||
.
|
||||
|
||||
.PHONY: skycraft-dev
|
||||
skycraft-dev: skycraft-dev-image
|
||||
docker run -it --rm \
|
||||
-v .:/workspace \
|
||||
-v /workspace/skycraft/node_modules \
|
||||
-p 8000:8000 \
|
||||
$(skycraft-dev-image)
|
||||
|
||||
.PHONY: help
|
||||
help: ## Show this help
|
||||
@echo Noteworthy targets:
|
||||
@egrep '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
.DEFAULT_GOAL := help
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "wmc-common",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.14.2"
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { makeFace } from 'wmc-common/geometry';
|
||||
import { makeFace } from '../geometry';
|
||||
import * as linalg from './linalg';
|
||||
import {memoize} from 'wmc-common/memoize';
|
||||
import {memoize} from '../memoize';
|
||||
|
||||
type direction = ('-x' | '+x' | '-y' | '+y' | '-z' | '+z');
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {makeBufferFromFaces } from 'wmc-common/geometry';
|
||||
import { loadTexture, makeProgram } from 'wmc-common/gl';
|
||||
import {makeBufferFromFaces } from '../geometry';
|
||||
import { loadTexture, makeProgram } from '../gl';
|
||||
import * as linalg from './linalg';
|
||||
import * as se3 from 'wmc-common/se3';
|
||||
import * as se3 from '../se3';
|
||||
import { makeOrbitObject } from './orbit';
|
||||
|
||||
const VSHADER = `
|
||||
@ -15,14 +15,12 @@ uniform mat4 uView;
|
||||
uniform vec3 uLightDirection;
|
||||
uniform float uAmbiantLight;
|
||||
uniform vec3 uGlowColor;
|
||||
uniform vec3 uSpecularColor;
|
||||
|
||||
varying highp vec2 vTextureCoord;
|
||||
varying lowp vec3 vLighting;
|
||||
varying lowp vec3 vRay;
|
||||
varying lowp vec3 vLightDir;
|
||||
varying lowp vec3 vNormal;
|
||||
varying lowp vec3 vSpecularColor;
|
||||
|
||||
highp mat3 transpose(in highp mat3 inmat) {
|
||||
highp vec3 x = inmat[0];
|
||||
@ -52,7 +50,6 @@ void main() {
|
||||
vRay = -normalize((uModel * vec4(aPosition, 1.0)).xyz - camPos);
|
||||
vLightDir = -uLightDirection;
|
||||
vNormal = normal;
|
||||
vSpecularColor = uSpecularColor;
|
||||
}
|
||||
`;
|
||||
|
||||
@ -64,7 +61,6 @@ varying lowp vec3 vLighting;
|
||||
varying lowp vec3 vRay;
|
||||
varying lowp vec3 vLightDir;
|
||||
varying lowp vec3 vNormal;
|
||||
varying lowp vec3 vSpecularColor;
|
||||
|
||||
void main() {
|
||||
highp vec4 color = texture2D(uSampler, vTextureCoord);
|
||||
@ -73,7 +69,7 @@ void main() {
|
||||
}
|
||||
lowp vec3 specularDir = 2.0 * dot(vLightDir, vNormal) * vNormal - vLightDir;
|
||||
lowp float specularAmount = smoothstep(0.92, 1.0, dot(vRay, specularDir));
|
||||
lowp vec3 specular = specularAmount * vSpecularColor;
|
||||
lowp vec3 specular = 0.8 * specularAmount * vec3(1.0, 1.0, 0.8);
|
||||
gl_FragColor = vec4(vLighting * color.rgb + specular, color.a);
|
||||
}
|
||||
`;
|
||||
@ -90,7 +86,6 @@ export async function initWorldGl(gl: WebGLRenderingContext) {
|
||||
const lightDirectionLoc = gl.getUniformLocation(program, 'uLightDirection');
|
||||
const ambiantLoc = gl.getUniformLocation(program, 'uAmbiantLight');
|
||||
const glowColorLoc = gl.getUniformLocation(program, 'uGlowColor');
|
||||
const specularColorLoc = gl.getUniformLocation(program, 'uSpecularColor');
|
||||
|
||||
const positionLoc = gl.getAttribLocation(program, 'aPosition');
|
||||
const normalLoc = gl.getAttribLocation(program, 'aNormal');
|
||||
@ -128,14 +123,12 @@ export async function initWorldGl(gl: WebGLRenderingContext) {
|
||||
numVertices,
|
||||
lightDirection,
|
||||
glowColor,
|
||||
specularColor,
|
||||
} = objectParams;
|
||||
|
||||
gl.uniformMatrix4fv(modelLoc, false, new Float32Array(se3.product(
|
||||
se3.translation(...position), orientation)));
|
||||
gl.uniform3fv(lightDirectionLoc, lightDirection);
|
||||
gl.uniform3fv(glowColorLoc, glowColor);
|
||||
gl.uniform3fv(specularColorLoc, specularColor);
|
||||
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, glBuffer);
|
||||
|
||||
@ -247,7 +240,7 @@ export function getOrbitDrawContext(gl: WebGLRenderingContext) {
|
||||
function getObjects(context, body, parentPosition = undefined) {
|
||||
const objects = [];
|
||||
const {gl, glContext, player} = context;
|
||||
const {position, orientation, glowColor, specularColor} = body;
|
||||
const {position, orientation, glowColor} = body;
|
||||
|
||||
if (body.glBuffer === undefined) {
|
||||
body.glBuffer = makeBufferFromFaces(gl, body.geometry);
|
||||
@ -259,7 +252,6 @@ function getObjects(context, body, parentPosition = undefined) {
|
||||
position,
|
||||
glContext,
|
||||
glowColor,
|
||||
specularColor,
|
||||
});
|
||||
if (parentPosition !== undefined) {
|
||||
const orbitObject = makeOrbitObject(gl, context.orbitGlContext, body.orbit, parentPosition);
|
||||
@ -276,7 +268,6 @@ function getObjects(context, body, parentPosition = undefined) {
|
||||
orientation: shipOrientation,
|
||||
position: shipPos,
|
||||
glContext,
|
||||
specularColor: [0.8, 0.8, 0.8],
|
||||
});
|
||||
}
|
||||
|
||||
@ -320,7 +311,7 @@ export function draw(context) {
|
||||
].reduce(se3.product));
|
||||
let lastGlContext;
|
||||
|
||||
for (const {position, orientation, geometry, glContext, glowColor, specularColor} of objects) {
|
||||
for (const {position, orientation, geometry, glContext, glowColor} of objects) {
|
||||
if (glContext !== lastGlContext) {
|
||||
glContext.setupScene({
|
||||
projectionMatrix: projMatrix,
|
||||
@ -339,7 +330,6 @@ export function draw(context) {
|
||||
numVertices: geometry.numVertices,
|
||||
lightDirection,
|
||||
glowColor: glowColor || [0, 0, 0],
|
||||
specularColor: specularColor || [0, 0, 0],
|
||||
});
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
import { makeFace } from 'wmc-common/geometry';
|
||||
import { makeFace } from '../geometry';
|
||||
|
||||
import * as linalg from './linalg';
|
||||
import { loadObjModel } from './obj';
|
||||
import * as se3 from 'wmc-common/se3';
|
||||
import * as se3 from '../se3';
|
||||
import { computeOrbit, findSoi, getCartesianState, updateBodyPhysics } from './orbit';
|
||||
import { getBodyGeometry } from './chunk';
|
||||
import { draw, getOrbitDrawContext, initWorldGl } from './draw';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as se3 from 'wmc-common/se3';
|
||||
import * as se3 from '../se3';
|
||||
import * as linalg from './linalg';
|
||||
import {Vec3} from './linalg';
|
||||
|
||||
|
@ -4,12 +4,11 @@
|
||||
"main": "index.ts",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.14.2",
|
||||
"wmc-common": "link:../common"
|
||||
"esbuild": "^0.14.2"
|
||||
},
|
||||
"scripts": {
|
||||
"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",
|
||||
"watch": "esbuild --outfile=app.js index.ts --bundle --sourcemap=inline --watch",
|
||||
"serve": "esbuild --outfile=app.js index.ts --bundle --sourcemap=inline --servedir=.",
|
||||
"build": "esbuild --outfile=app.js index.ts --bundle --minify"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Mat4} from './linalg';
|
||||
import * as se3 from 'wmc-common/se3';
|
||||
import * as se3 from '../se3';
|
||||
|
||||
export interface Quat {
|
||||
x: number,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 40 KiB |
1
skycraft/texture.png
Symbolic link
1
skycraft/texture.png
Symbolic link
@ -0,0 +1 @@
|
||||
../texture.png
|
@ -44,7 +44,7 @@ esbuild-linux-32@0.14.54:
|
||||
|
||||
esbuild-linux-64@0.14.54:
|
||||
version "0.14.54"
|
||||
resolved "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz"
|
||||
resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz#de5fdba1c95666cf72369f52b40b03be71226652"
|
||||
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.npmjs.org/esbuild/-/esbuild-0.14.54.tgz"
|
||||
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.54.tgz#8b44dcf2b0f1a66fc22459943dccf477535e9aa2"
|
||||
integrity sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==
|
||||
optionalDependencies:
|
||||
"@esbuild/linux-loong64" "0.14.54"
|
||||
@ -133,7 +133,3 @@ 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 ""
|
||||
|
Loading…
Reference in New Issue
Block a user