Created
November 9, 2020 04:17
-
-
Save erickzhao/160cf9bf0e5fa8a6b8ede86d569e60a2 to your computer and use it in GitHub Desktop.
testing 2
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>My first three.js app</title> | |
| <style> | |
| body { margin: 0; } | |
| canvas { display: block; } | |
| </style> | |
| </head> | |
| <body> | |
| <script src="https://threejs.org/build/three.js"></script> | |
| <script src="renderer.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or 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
| // Modules to control application life and create native browser window | |
| const {app, BrowserWindow} = require('electron') | |
| // edit | |
| function createWindow () { | |
| // Create the browser window. | |
| const mainWindow = new BrowserWindow({ | |
| width: 800, | |
| height: 600, | |
| webPreferences: { | |
| nodeIntegration: true | |
| } | |
| }) | |
| // and load the index.html of the app. | |
| mainWindow.loadFile('index.html') | |
| mainWindow.getWebContentsId() | |
| // Open the DevTools. | |
| // mainWindow.webContents.openDevTools() | |
| } | |
| // This method will be called when Electron has finished | |
| // initialization and is ready to create browser windows. | |
| // Some APIs can only be used after this event occurs. | |
| app.whenReady().then(createWindow) | |
| // Quit when all windows are closed, except on macOS. There, it's common | |
| // for applications and their menu bar to stay active until the user quits | |
| // explicitly with Cmd + Q. | |
| app.on('window-all-closed', function () { | |
| if (process.platform !== 'darwin') { | |
| app.quit() | |
| } | |
| }) | |
| app.on('activate', function () { | |
| // On OS X it's common to re-create a window in the app when the | |
| // dock icon is clicked and there are no other windows open. | |
| if (BrowserWindow.getAllWindows().length === 0) { | |
| createWindow() | |
| } | |
| }) | |
| // In this file you can include the rest of your app's specific main process | |
| // code. You can also put them in separate files and require them here. |
This file contains hidden or 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
| // Empty |
This file contains hidden or 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
| var scene = new THREE.Scene(); | |
| var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 ); | |
| var renderer = new THREE.WebGLRenderer(); | |
| renderer.setSize( window.innerWidth, window.innerHeight ); | |
| document.body.appendChild( renderer.domElement ); | |
| var geometry = new THREE.BoxGeometry( 1, 1, 1 ); | |
| var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); | |
| var cube = new THREE.Mesh( geometry, material ); | |
| scene.add( cube ); | |
| camera.position.z = 5; | |
| var animate = function () { | |
| requestAnimationFrame( animate ); | |
| cube.rotation.x += 0.01; | |
| cube.rotation.y += 0.01; | |
| renderer.render( scene, camera ); | |
| }; | |
| animate(); |
This file contains hidden or 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
| /* Empty */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment