diff --git a/package-lock.json b/package-lock.json index df4d12aac59e87d7c5b3d2ca578886a074b52f2e..9a14a78b688d55a4ea47254ba66718067ba6db43 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/package.json b/package.json index 6329b7aac9ebdd98d7744b76e297454dee65fd6b..db448a52d1dcdb903d498c4c9fca2fad7938f1db 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "scripts": { "lint": "tslint src/**/*.ts", "build": "tsc", + "postbuild": "copyfiles --up 1 src/mol-gl/shader/*.vert src/mol-gl/shader/*.frag build/node_modules/", "watch": "tsc -watch", "test": "jest", "script": "node build/node_modules/script.js", @@ -31,13 +32,14 @@ "build/node_modules" ], "moduleNameMapper": { - "mol-task($|/.*)": "<rootDir>/src/mol-task$1", - "mol-comp($|/.*)": "<rootDir>/src/mol-comp$1", - "mol-util($|/.*)": "<rootDir>/src/mol-util$1", "mol-data($|/.*)": "<rootDir>/src/mol-data$1", - "mol-math($|/.*)": "<rootDir>/src/mol-math$1", + "mol-gl($|/.*)": "<rootDir>/src/mol-gl$1", "mol-io($|/.*)": "<rootDir>/src/mol-io$1", - "mol-model($|/.*)": "<rootDir>/src/mol-model$1" + "mol-math($|/.*)": "<rootDir>/src/mol-math$1", + "mol-model($|/.*)": "<rootDir>/src/mol-model$1", + "mol-ql($|/.*)": "<rootDir>/src/mol-ql$1", + "mol-task($|/.*)": "<rootDir>/src/mol-task$1", + "mol-util($|/.*)": "<rootDir>/src/mol-util$1" }, "testRegex": "\\.spec\\.ts$" }, @@ -53,7 +55,10 @@ "@types/react": "^16.0.4", "@types/react-dom": "^16.0.4", "benchmark": "^2.1.4", + "copyfiles": "^2.0.0", + "glslify-loader": "^1.0.2", "jest": "^22.4.2", + "raw-loader": "^0.5.1", "regl": "git+https://github.com/regl-project/regl.git#45c6ec570232420fca21567499c9c5a2a054432e", "rollup": "^0.56.2", "rollup-plugin-buble": "^0.19.2", diff --git a/src/apps/render-test/state.ts b/src/apps/render-test/state.ts index 36f9c6192595e096e324d281081b18b43b5771ac..b5d995ae342ffbc9b1f63c60896e95e1906d93e4 100644 --- a/src/apps/render-test/state.ts +++ b/src/apps/render-test/state.ts @@ -9,6 +9,9 @@ import * as glContext from 'mol-gl/context' import { Camera } from 'mol-gl/camera' import { Vec3 } from 'mol-math/linear-algebra' +const pointVert = require('mol-gl/shader/point.vert') +const pointFrag = require('mol-gl/shader/point.frag') + export default class State { regl: REGL.Regl @@ -28,33 +31,21 @@ export default class State { center: Vec3.create(0, 0, 0) }) - const drawTriangle = regl({ - frag: ` - void main() { - gl_FragColor = vec4(1, 0, 0, 1); - }`, - - vert: ` - precision mediump float; - uniform mat4 projection, view; - attribute vec3 position; - void main () { - gl_Position = projection * view * vec4(position, 1.0); - }`, - + const drawPoints = regl({ + vert: pointVert, + frag: pointFrag, attributes: { position: [[0, -1, 0], [-1, 0, 0], [1, 1, 0]] }, - - count: 3 + count: 3, + primitive: 'points' }) regl.frame(() => { camera.update((state: any) => { if (!camera.isDirty()) return - console.log(state, camera) regl.clear({color: [0, 0, 0, 1]}) - drawTriangle() + drawPoints() }, undefined) }) diff --git a/src/mol-gl/camera.ts b/src/mol-gl/camera.ts index 0785b4e15740fa0720ef826ebb7a6ecdda34bee3..c2965e48c73ca19c47dee440f6dc54a9780e0fdb 100644 --- a/src/mol-gl/camera.ts +++ b/src/mol-gl/camera.ts @@ -177,9 +177,6 @@ export namespace Camera { function update (props: any, block: any) { setState() injectContext(props, block) - if (dirty) { - console.log(view) - } dirty = false } diff --git a/src/mol-gl/shader/point.frag b/src/mol-gl/shader/point.frag new file mode 100644 index 0000000000000000000000000000000000000000..294326afac39be65de8cdccb4d7d02dc674b2821 --- /dev/null +++ b/src/mol-gl/shader/point.frag @@ -0,0 +1,3 @@ +void main(){ + gl_FragColor = vec4(1, 0, 0, 1); +} \ No newline at end of file diff --git a/src/mol-gl/shader/point.vert b/src/mol-gl/shader/point.vert new file mode 100644 index 0000000000000000000000000000000000000000..3e3b673b520f739d815581d1338158bcdc441ff2 --- /dev/null +++ b/src/mol-gl/shader/point.vert @@ -0,0 +1,10 @@ +precision mediump float; +uniform mat4 projection, view; +attribute vec3 position; + +varying vec3 vPosition; + +void main(){ + gl_PointSize = 20.0; + gl_Position = projection * view * vec4(position, 1.0); +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index f8761db56ee42b220f37b1a7991e4209521b7694..8c7f443865474f7221f0ef0cd3a0fcb2035ec020 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,13 +14,14 @@ "outDir": "build/node_modules", "baseUrl": "src", "paths": { - "mol-task": ["./mol-task", "./mol-task/index.ts"], - "mol-comp": ["./mol-comp", "./mol-comp/index.ts"], - "mol-util": ["./mol-util", "./mol-util/index.ts"], "mol-data": ["./mol-data", "./mol-data/index.ts"], - "mol-math": ["./mol-math"], + "mol-gl": ["./mol-gl"], "mol-io": ["./mol-io"], - "mol-model": ["./mol-model"] + "mol-math": ["./mol-math"], + "mol-model": ["./mol-model"], + "mol-ql": ["./mol-ql"], + "mol-task": ["./mol-task", "./mol-task/index.ts"], + "mol-util": ["./mol-util", "./mol-util/index.ts"], } }, "include": [ "**/*" ] diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000000000000000000000000000000000000..a6c2bea5f0f1cc24ad8390031d0abdc0d673ef8d --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,14 @@ +module.exports = { + module: { + rules: [ + { + test: /\.(glsl|frag|vert)$/, + loader: 'raw-loader', + }, + { + test: /\.(glsl|frag|vert)$/, + loader: 'glslify-loader', + } + ] + } +} \ No newline at end of file