-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated from npm to yarn. Worked on typescript
- Loading branch information
Showing
37 changed files
with
863 additions
and
94 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
ARGS = -s INITIAL_MEMORY=671088640 -fsanitize=address -s ALLOW_MEMORY_GROWTH=1 --emit-symbol-map --bind -g4 --no-entry -s USE_GLFW=3 -I../../raylib/src -I../../include -L../../raylib/src/ -lraylib --shell-file=../../raylib/src/shell.html ../../bin/raylibweb.bc | ||
|
||
all: core models | ||
|
||
core: dependency | ||
cd core && emmake make ARGS="--source-map-base /example/core/ $(ARGS)" | ||
|
||
models: dependency | ||
cd models && emmake make ARGS="--source-map-base /example/models/ $(ARGS)" | ||
|
||
dependency: | ||
cd ../src/WebAssembly && emmake make static BUILD=DEBUG | ||
all: | ||
cd ../src/TypeScript && make examples | ||
../node_modules/.bin/tsc -p ./core/BasicWindow/tsconfig.json | ||
../node_modules/.bin/tsc -p ./models/MeshGeneration/tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import Raylib from "../../../bin/raylibWeb.js"; | ||
function loop() { | ||
|
||
Module.BeginDrawing(); | ||
|
||
Module.ClearBackground({ r: 245, g: 245, b: 245, a: 255 }); | ||
|
||
Module.DrawText("Congrats! You created your first window!", 190, 200, 20, { r: 200, g: 200, b: 200, a: 255 }) | ||
|
||
Module.EndDrawing(); | ||
Raylib.raylibC.BeginDrawing(); | ||
Raylib.raylibC.ClearBackground({ r: 245, g: 245, b: 245, a: 255 }); | ||
Raylib.raylibC.DrawText("Congrats! You created your first window!", 190, 200, 20, { r: 200, g: 200, b: 200, a: 255 }); | ||
Raylib.raylibC.EndDrawing(); | ||
setTimeout(loop); | ||
} | ||
|
||
Module.onRuntimeInitialized = function () { | ||
Module.SetLoop(loop); | ||
Module.InitWindow(800, 450); | ||
} | ||
Raylib.raylibC.InitWindow(800, 450); | ||
loop(); | ||
}; | ||
Raylib.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Raylib from "../../../bin/raylibWeb.js"; | ||
|
||
declare let Module: any; | ||
|
||
function loop() { | ||
Raylib.raylibC.BeginDrawing(); | ||
|
||
Raylib.raylibC.ClearBackground({ r: 245, g: 245, b: 245, a: 255 }); | ||
|
||
(Raylib.raylibC as any).DrawText("Congrats! You created your first window!", 190, 200, 20, { r: 200, g: 200, b: 200, a: 255 }) | ||
|
||
Raylib.raylibC.EndDrawing(); | ||
|
||
setTimeout(loop); | ||
} | ||
|
||
Module.onRuntimeInitialized = function () { | ||
Raylib.raylibC.InitWindow(800, 450); | ||
loop(); | ||
} | ||
|
||
Raylib.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "ES6", | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"strict": true, | ||
"target": "ES6", | ||
"sourceMap": false | ||
}, | ||
"include": ["./*"], | ||
"exclude": ["node_modules", "**/*.spec.ts"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
var Module: any; | ||
if (Module === undefined) { | ||
Module = {}; | ||
} | ||
let models: any[] = []; | ||
let texture; | ||
|
||
let camera = { position: { x: 5.0, y: 5.0, z: 5.0 }, target: { x: 0.0, y: 0.0, z: 0.0 }, up: { x: 0.0, y: 1.0, z: 0.0 }, rotation: 45.0, zoom: 0, fovy: 90, type: 0 }; | ||
|
||
let position = { x: 0.0, y: 0.0, z: 0.0 }; | ||
|
||
let current = 0; | ||
|
||
Module.onRuntimeInitialized = function () { | ||
Module.InitWindow(1920, 1080); | ||
|
||
let checked = Module.GenImageChecked(2, 2, 1, 1, { r: 255, g: 0, b: 0, a: 255 }, { r: 0, g: 255, b: 0, a: 255 }); | ||
|
||
texture = Module.LoadTextureFromImage(checked); | ||
|
||
Module.UnloadImage(checked); | ||
|
||
models.push(Module.LoadModelFromMesh(Module.GenMeshPlane(2, 2, 5, 5))); | ||
models.push(Module.LoadModelFromMesh(Module.GenMeshCube(2.0, 1.0, 2.0))); | ||
models.push(Module.LoadModelFromMesh(Module.GenMeshSphere(2, 32, 32))); | ||
models.push(Module.LoadModelFromMesh(Module.GenMeshHemiSphere(2, 16, 16))); | ||
models.push(Module.LoadModelFromMesh(Module.GenMeshCylinder(1, 2, 16))); | ||
models.push(Module.LoadModelFromMesh(Module.GenMeshTorus(0.25, 4.0, 16, 32))); | ||
models.push(Module.LoadModelFromMesh(Module.GenMeshKnot(1.0, 2.0, 16, 128))); | ||
models.push(Module.LoadModelFromMesh(Module.GenMeshPoly(5, 2.0))); | ||
|
||
for (let i = 0; i < models.length; i++) { | ||
Module.SetModelTexture(models[i], 0, 0, texture); | ||
} | ||
|
||
Module.SetCameraMode(camera, 2); | ||
|
||
loop(); | ||
} | ||
|
||
function loop() { | ||
camera = Module.UpdateCamera(camera); | ||
|
||
if (Module.IsMouseButtonPressed(0)) { | ||
current = (current + 1) % models.length; | ||
} | ||
|
||
if (Module.IsKeyPressed(262)) { | ||
current++; | ||
|
||
if (current >= models.length) { | ||
current = 0; | ||
} | ||
} else if (Module.IsKeyPressed(263)) { | ||
current--; | ||
|
||
if (current < 0) { | ||
current = models.length - 1; | ||
} | ||
} | ||
|
||
Module.BeginDrawing(); | ||
|
||
Module.ClearBackground({ r: 245, g: 245, b: 245, a: 255 }); | ||
|
||
Module.BeginMode3D(camera); | ||
|
||
Module.DrawModel(models[current], position, 1.0, {r: 255, g: 255, b: 255, a: 255}); | ||
|
||
Module.DrawGrid(10, 1.0); | ||
|
||
Module.EndMode3D(); | ||
|
||
Module.DrawFPS(0, 0); | ||
|
||
Module.EndDrawing(); | ||
|
||
setTimeout(loop); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "ES6", | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"strict": true, | ||
"target": "ES6", | ||
"sourceMap": false | ||
}, | ||
"include": ["./*"], | ||
"exclude": ["node_modules", "**/*.spec.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "ES6", | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"strict": true, | ||
"target": "ES6", | ||
"sourceMap": false | ||
}, | ||
"include": ["./*"], | ||
"exclude": ["node_modules", "**/*.spec.ts"] | ||
} |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "raylib-js", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"repository": "[email protected]:NimbusFox/raylib-js.git", | ||
"author": "NimbusFox <[email protected]>", | ||
"license": "Zlib", | ||
"dependencies": { | ||
"typescript": "^4.1.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
debug: copyDefinitions | ||
tsc -p ./tsconfig.debug.json | ||
debug: dependencies | ||
../../node_modules/.bin/tsc -p ./tsconfig.debug.json | ||
|
||
release: copyDefinitions | ||
tsc -p ./tsconfig.release.json | ||
./node_modules/.bin/browserify ../../bin/js/raylibWeb.js -o ../../bin/raylibWeb.js | ||
release: dependencies ts_release | ||
|
||
examples: ts_release | ||
cd ../WebAssembly && emmake make examples MODULE=TRUE | ||
|
||
copyDefinitions: | ||
cp -r ./definitions/*.d.ts ../../bin/typescript | ||
ts_release: | ||
../../node_modules/.bin/tsc -p ./tsconfig.release.json | ||
|
||
dependencies: | ||
cd ../WebAssembly && emmake make build MODULE=TRUE |
Oops, something went wrong.