Skip to content

Commit

Permalink
Merge pull request #7 from Microtome/modernize_drawables
Browse files Browse the repository at this point in the history
Modernize drawables part of program
  • Loading branch information
DanielJoyce authored Feb 8, 2024
2 parents b5fc590 + 33ae565 commit 2b76fdb
Show file tree
Hide file tree
Showing 17 changed files with 1,006 additions and 613 deletions.
36 changes: 36 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
// For rules: https://eslint.style/rules
plugins: [
'@stylistic'
],
'env': {
'browser': true,
'es2023': true
},
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module'
},
'rules': {
'@stylistic/indent': [
'error',
2
],
'@stylistic/linebreak-style': [
'error',
'unix'
],
'@stylistic/quotes': [
'error',
'single'
],
'@stylistic/semi': [
'error',
'always'
],
'@stylistic/max-len': [
'error',
100
],
}
};
28 changes: 0 additions & 28 deletions .eslintrc.json

This file was deleted.

15 changes: 15 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"jsx": "react",
"allowImportingTsExtensions": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"devDependencies": {
"@parcel/reporter-bundle-analyzer": "^2.11.0",
"@parcel/transformer-glsl": "^2.11.0",
"@stylistic/eslint-plugin": "^1.6.0",
"eslint": "^8.56.0",
"parcel": "^2.11.0"
},
Expand All @@ -30,4 +31,4 @@
"bugs": {
"url": "https://github.com/stephomi/sculptgl/issues"
}
}
}
27 changes: 23 additions & 4 deletions src/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ class Scene {
// CONTOUR 1/2
///////////////
gl.disable(gl.DEPTH_TEST);
var showContour = this._selectMeshes.length > 0 && this._showContour && ShaderLib[Enums.Shader.CONTOUR].color[3] > 0.0;

let showContour = this._selectMeshes.length > 0
&& this._showContour
&& ShaderLib[Enums.Shader.CONTOUR].color[3] > 0.0;

if (showContour) {
gl.bindFramebuffer(gl.FRAMEBUFFER, this._rttContour.getFramebuffer());
gl.clear(gl.COLOR_BUFFER_BIT);
Expand Down Expand Up @@ -367,7 +371,10 @@ class Scene {
};

var canvas = document.getElementById('canvas');
var gl = this._gl = canvas.getContext('webgl', attributes) || canvas.getContext('experimental-webgl', attributes);

var gl = this._gl = canvas.getContext('webgl', attributes)
|| canvas.getContext('experimental-webgl', attributes);

if (!gl) {
window.alert('Could not initialise WebGL. No WebGL, no SculptGL. Sorry.');
return;
Expand Down Expand Up @@ -489,7 +496,11 @@ class Scene {

var mCen = mat4.create();
mat4.scale(mCen, mCen, [scale, scale, scale]);
mat4.translate(mCen, mCen, [-(box[0] + box[3]) * 0.5, -(box[1] + box[4]) * 0.5, -(box[2] + box[5]) * 0.5]);
mat4.translate(
mCen,
mCen,
[-(box[0] + box[3]) * 0.5, -(box[1] + box[4]) * 0.5, -(box[2] + box[5]) * 0.5]
);

for (var i = 0, l = meshes.length; i < l; ++i) {
var mat = meshes[i].getMatrix();
Expand Down Expand Up @@ -522,7 +533,15 @@ class Scene {
}

addTorus(preview) {
var mesh = new Multimesh(Primitives.createTorus(this._gl, this._torusLength, this._torusWidth, this._torusRadius, this._torusRadial, this._torusTubular));
var mesh = new Multimesh(
Primitives.createTorus(
this._gl,
this._torusLength,
this._torusWidth,
this._torusRadius,
this._torusRadial,
this._torusTubular)
);
if (preview) {
mesh.setShowWireframe(true);
var scale = 0.3 * Utils.SCALE;
Expand Down
141 changes: 0 additions & 141 deletions src/drawables/Background.js

This file was deleted.

Loading

0 comments on commit 2b76fdb

Please sign in to comment.