Skip to content

Commit

Permalink
Update for node 22
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Nov 3, 2024
1 parent 6b47ff6 commit 4c29ce7
Show file tree
Hide file tree
Showing 14 changed files with 523 additions and 347 deletions.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] ___ doesn't work"
labels: bug
assignees: raub

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. ___
2. ___
3. ___

**Expected behavior**
Description of what you expected to happen.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEAT] ____"
labels: new
assignees: raub

---

**Describe the solution you'd like**
Description of what you want to happen.

**Describe alternatives you've considered**
Description of alternative solutions or features you've considered.
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Description
<!-- A concise description of what the PR does. -->


## Test Plan
<!-- How can a reviewer test the changes included in this PR? -->
1.
2.
3.


## Checklist
<!-- Ensure that your PR fulfills the following requirements -->
- [ ] I've followed the code style.
- [ ] I've tried running the code with my changes.
- [ ] The docs and TS declarations are in sync with code changes.
- [ ] (optional) I've added unit tests for my changes.
2 changes: 1 addition & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.14.0
node-version: 22.9.0
cache: 'npm'

- name: Install Modules
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.14.0
node-version: 22.9.0
cache: 'npm'

- name: Get Package Version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.14.0
node-version: 22.9.0
cache: 'npm'

- name: Install Modules
Expand Down
18 changes: 18 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Code of Conduct

We pledge to act and interact in ways that contribute to an open and healthy community.

## Our Standards

Examples of unacceptable behavior:

* The use of sexualized language or imagery
* Trolling, insulting or derogatory comments
* Public or private harassment
* Publishing others' private information
* Other unprofessional conduct

## Enforcement

Community leaders will remove, edit, or reject
contributions that are not aligned to this Code of Conduct.
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Contributing

Bugs and enhancements are tracked as GitHub issues.

## Issues

* Use a clear and descriptive title.
* Describe the desired enhancement / problem.
* Provide examples to demonstrate the issue.
* If the problem involves a crash, provide its trace log.

## Pull Requests

* Do not include issue numbers in the PR title.
* Commits use the present tense (`"Add feature"` not `"Added feature"`).
* Commits use the imperative mood (`"Move cursor to..."` not `"Moves cursor to..."`).
* File System
* Prefer kebab-lowercase (`my-dir/example-file-name.js`).
* Place an empty `.keep` file to keep an empty directory.
11 changes: 11 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Security Policy

## Supported Versions

Latest major version.

## Reporting a Vulnerability

Email: luisblanco1337@gmail.com.

Telegram: [luisblanco_0](https://t.me/luisblanco_0)
2 changes: 1 addition & 1 deletion examples/srgb/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions examples/three/knot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Init Node3D environment
const three = require('three');
const { init, addThreeHelpers } = require('../..');
const { doc, gl, requestAnimationFrame } = init({ isGles3: true, isWebGL2: true, vsync: false });
addThreeHelpers(three, gl);

// Three.js rendering setup
const renderer = new three.WebGLRenderer();
const scene = new three.Scene();
const camera = new three.PerspectiveCamera(70, doc.w / doc.h, 0.2, 500);
camera.position.z = 35;
scene.background = new three.Color(0x333333);

// Add scene lights
scene.add(new three.AmbientLight(0xc1c1c1, 0.5));
const sun = new three.DirectionalLight(0xffffff, 2);
sun.position.set(-1, 0.5, 1);
scene.add(sun);

// Original knot mesh
const knotGeometry = new three.TorusKnotGeometry(10, 1.85, 256, 20, 2, 7);
const knotMaterial = new three.MeshToonMaterial({ color: 0x6cc24a });
const knotMesh = new three.Mesh(knotGeometry, knotMaterial);
scene.add(knotMesh);

// A slightly larger knot mesh, inside-out black - for outline
const outlineGeometry = new three.TorusKnotGeometry(10, 2, 256, 20, 2, 7);
const outlineMaterial = new three.MeshBasicMaterial({ color: 0, side: three.BackSide });;
const outlineMesh = new three.Mesh(outlineGeometry, outlineMaterial);
knotMesh.add(outlineMesh);

// Handle window resizing
doc.addEventListener('resize', () => {
camera.aspect = doc.w / doc.h;
camera.updateProjectionMatrix();
renderer.setSize(doc.w, doc.h);
});

// Called repeatedly to render new frames
const animate = () => {
requestAnimationFrame(animate);
const time = Date.now();
knotMesh.rotation.x = time * 0.0005;
knotMesh.rotation.y = time * 0.001;
renderer.render(scene, camera);
};

animate();
27 changes: 20 additions & 7 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,32 @@ const _init = (_opts = {}) => {

const doc = new Document({ ...optsDoc, onBeforeWindow });

global.self = global;
global.globalThis = global;
global.addEventListener = doc.addEventListener.bind(doc);
global.removeEventListener = doc.removeEventListener.bind(doc);
if (!global.self) {
global.self = global;
}

if (!global.globalThis) {
global.globalThis = global;
}

global.document = doc;
global.window = doc;
global.body = doc;
global.cwrap = null;
global.addEventListener = doc.addEventListener.bind(doc);
global.removeEventListener = doc.removeEventListener.bind(doc);
global.requestAnimationFrame = doc.requestAnimationFrame;
global.cancelAnimationFrame = doc.cancelAnimationFrame;
global.location = location;
doc.location = location;
global.navigator = navigator;

if (!global.location) {
global.location = location;
}
doc.location = global.location;

if (!global.navigator) {
global.navigator = navigator;
}

global.WebVRManager = WebVRManager;
global.Image = Image;
global._gl = webgl;
Expand Down
Loading

0 comments on commit 4c29ce7

Please sign in to comment.