Giter Club home page Giter Club logo

studybabylonjs's Introduction

studybabylonjs

這是學習babylogjs的

00_babylonjs-ts-template

建立基本的專案結構(參考)[https://reddotblues.medium.com/babylon-js-typescript-project-setup-for-the-impatient-d8c71b4a57ad]

npm init
npm install --save-dev typescript webpack ts-loader webpack-cli
npm install babylonjs --save
npm install babylonjs-gui --save

建立檔案webpack.config.js

const path = require('path')

module.exports = {
    mode: "development",
    entry: {
        app: "./src/app.ts"
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].js'
    },
    resolve: {
        extensions: ['.ts', 'tsx', '.js']
    },
    devtool: 'source-map',
    plugins: [],
    module: {
        rules: [{
            test: /\.tsx?$/,
            loader: 'ts-loader',
            exclude: /node_modules/
        }]
    }
}

建立tsconfig.json

{
    "compileOnSave": true,
    "compilerOptions": {
        "target": "ES2015",
        "module": "ES2015",
        "sourceMap": true,
        "outDir": "./dist",
        "types": [
            "babylonjs",
            "babylonjs-gui",
        ]
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.js"
    ]
}

修改package.json

"scripts": {
    "build": "webpack",
    "watch": "webpack -w",
    "test": "echo \"Error: no test specified\" && exit 1"
},

建立index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Six</title>
    <style>
        html,body {overflow: hidden;width: 100%;height: 100%;margin: 0;padding: 0;}
        #renderCanvas {width: 100%;height: 100%;touch-action: none;}
    </style>
</head>
<body>
    <canvas id="renderCanvas" touch-action="none"></canvas>
    <script src="dist/app.js"></script>
</body>
</html>

建立src資料夾和app.ts

tobuild

npm run build

自動

npm run watch

studybabylonjs's People

Contributors

ttom921 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.