Skip to content

Commit

Permalink
cleaned up code for linting errors (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpal81xd authored Apr 8, 2024
1 parent 2b1ce79 commit 40c81b0
Show file tree
Hide file tree
Showing 13 changed files with 609 additions and 605 deletions.
308 changes: 187 additions & 121 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@playcanvas/eslint-config": "^1.7.1",
"@playcanvas/observer": "^1.4.0",
"@playcanvas/pcui": "^4.2.0",
"@playcanvas/pcui": "^4.3.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-image": "^3.0.3",
Expand All @@ -67,13 +67,13 @@
"eslint": "^8.56.0",
"fflate": "^0.8.2",
"handlebars": "^4.7.8",
"playcanvas": "^1.68.2",
"playcanvas": "^1.69.2",
"prop-types": "^15.8.1",
"qrious": "^4.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-visibility-sensor": "^5.1.1",
"rollup": "^4.12.0",
"rollup": "^4.14.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-sass": "^1.12.21",
"serve": "^14.2.1",
Expand Down
8 changes: 4 additions & 4 deletions copy-and-watch.mjs → plugins/copy-and-watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ export default function copyAndWatch(config) {

return {
name: 'copy-and-watch',
async buildStart() {
buildStart() {
resolvedConfig.targets.forEach((target) => {
this.addWatchFile(target.src);
});
},
async generateBundle() {
generateBundle() {
resolvedConfig.targets.forEach((target) => {
const contents = fs.readFileSync(target.src);
this.emitFile({
type: 'asset',
fileName: target.dest,
source: target.transform ? target.transform(contents, target.src) : contents
})
});
});
}
}
};
}
52 changes: 25 additions & 27 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// official rollup plugins
import alias from '@rollup/plugin-alias';
import copyAndWatch from "./copy-and-watch.mjs";
import image from '@rollup/plugin-image';
import commonjs from "@rollup/plugin-commonjs";
import Handlebars from 'handlebars';
Expand All @@ -11,6 +11,9 @@ import sass from 'rollup-plugin-sass';
import terser from '@rollup/plugin-terser';
import typescript from "@rollup/plugin-typescript";

// custom plugins
import copyAndWatch from "./plugins/copy-and-watch.mjs";

// prod is release build
if (process.env.BUILD_TYPE === 'prod') {
process.env.BUILD_TYPE = 'release';
Expand All @@ -25,24 +28,8 @@ const PCUI_DIR = path.resolve(process.env.PCUI_PATH || 'node_modules/@playcanvas
const ENGINE_NAME = (BUILD_TYPE === 'debug') ? 'playcanvas.dbg.mjs' : 'playcanvas.mjs';
const ENGINE_PATH = path.resolve(ENGINE_DIR, 'build', ENGINE_NAME);

// define supported module overrides
const aliasEntries = {
'playcanvas': ENGINE_PATH,
'playcanvas-extras': EXTRAS_DIR,
'pcui': PCUI_DIR
};

const tsCompilerOptions = {
baseUrl: '.',
paths: {
'playcanvas': [ENGINE_DIR],
'playcanvas-extras': [EXTRAS_DIR],
'pcui': [PCUI_DIR]
}
};

// compile mustache template
const compileMustache = (content, srcFilename) => {
const compileMustache = (content) => {
return Handlebars.compile(content.toString('utf8'))({
hasPublicPath: !!process.env.PUBLIC_PATH,
hasAnalyticsID: !!process.env.ANALYTICS_ID,
Expand All @@ -53,11 +40,6 @@ const compileMustache = (content, srcFilename) => {
});
};

const replaceValues = {
'process.env.NODE_ENV': JSON.stringify(BUILD_TYPE === 'release' ? 'production' : 'development'),
'__PUBLIC_PATH__': JSON.stringify(process.env.PUBLIC_PATH)
};

export default {
input: 'src/index.tsx',
output: {
Expand All @@ -74,20 +56,36 @@ export default {
]
}),
replace({
values: replaceValues,
values: {
'process.env.NODE_ENV': JSON.stringify(BUILD_TYPE === 'release' ? 'production' : 'development'),
'__PUBLIC_PATH__': JSON.stringify(process.env.PUBLIC_PATH)
},
preventAssignment: true
}),
sass({
insert: false,
output: 'dist/style.css',
outputStyle: 'compressed'
}),
image({dom: true}),
alias({ entries: aliasEntries }),
image({ dom: true }),
alias({
entries: {
'playcanvas': ENGINE_PATH,
'playcanvas-extras': EXTRAS_DIR,
'pcui': PCUI_DIR
}
}),
commonjs(),
resolve(),
typescript({
compilerOptions: tsCompilerOptions
compilerOptions: {
baseUrl: '.',
paths: {
'playcanvas': [ENGINE_DIR],
'playcanvas-extras': [EXTRAS_DIR],
'pcui': [PCUI_DIR]
}
}
}),
json(),
(BUILD_TYPE !== 'debug') && terser()
Expand Down
13 changes: 7 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import {
basisInitialize,
createGraphicsDevice,
Vec3,
WasmModule
WasmModule,
version as engineVersion,
revision as engineRevision
} from 'playcanvas';
import { Observer } from '@playcanvas/observer';

Expand All @@ -15,7 +17,6 @@ import './style.scss';

import { version as modelViewerVersion } from '../package.json';
import { version as pcuiVersion, revision as pcuiRevision } from 'pcui';
import { version as engineVersion, revision as engineRevision } from 'playcanvas';

// Permit some additional properties to be set on the window
declare global {
Expand Down Expand Up @@ -64,7 +65,7 @@ const observerData: ObserverData = {
},
skybox: {
value: 'Paul Lobe Haus',
options: JSON.stringify(['None'].concat(skyboxes.map(s => s.label)).map(l => { return { v: l, t: l } })),
options: JSON.stringify(['None'].concat(skyboxes.map(s => s.label)).map(l => ({ v: l, t: l }))),
exposure: 0,
rotation: 0,
background: 'Infinite Sphere',
Expand All @@ -74,7 +75,7 @@ const observerData: ObserverData = {
domeRadius: 20,
domeOffset: 0.4,
tripodOffset: 0.1
},
}
},
light: {
enabled: false,
Expand All @@ -85,7 +86,7 @@ const observerData: ObserverData = {
},
shadowCatcher: {
enabled: false,
intensity: 0.4,
intensity: 0.4
},
debug: {
renderMode: 'default',
Expand Down Expand Up @@ -282,7 +283,7 @@ const main = () => {
const url = decodeURIComponent(value);
files.push({ url, filename: url });
break;
};
}
case 'cameraPosition': {
const pos = value.split(',').map(Number);
if (pos.length === 3) {
Expand Down
154 changes: 0 additions & 154 deletions src/png-exporter.js

This file was deleted.

Loading

0 comments on commit 40c81b0

Please sign in to comment.