Giter Club home page Giter Club logo

vite-typescript-webgl's Introduction

TypeScript WebGL

///////////////////////////////////////////////////////////

安装环境

npm init

启动项目

npm run dev

///////////////////////////////////////////////////////////

搭建vite环境

1、npm init -y

#package.json

scripts改为:"dev": "vite"

2、安装vite:npm i vite -D

(建议node版本V14以上)

若无ts环境,安装:npm install -g typescript

////////////////////////////////////////////

合并ts为js

tsc --out main.js ***.ts ***.ts ***.ts

////////////////////////////////////////////

#index.html

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

<script type="text/javascript" src="./main.js"></script>

<style>
    
    html, body {padding: 0;margin: 0;overflow: hidden; }
    
    canvas {width: 100%;height: 100%;} 
    
</style>

//----------------------------章节摘要---------------------------------//

ts1

///////ts1 编译命令/////////////////////////////////////

tsc --out ./src/main.js ./src/app.ts

ts2

///////ts2 编译命令/////////////////////////////////////

tsc --out ./src/main.js ./src/engine.ts ./src/gl.ts ./src/app.ts

ts3

///////ts3 编译命令/////////////////////////////////////

tsc --out main.js ./src/app.ts ./src/engine.ts ./src/core/gl.ts ./src/core/shader.ts

显示:

ts4

///////ts4 编译命令/////////////////////////////////////

抽象出了:glBuffer.ts

编译命令:tsc --out main.js ./src/app.ts ./src/engine.ts ./src/core/gl.ts ./src/core/shader.ts ./src/core/glBuffer.ts

ts5

///////ts4 改写为import引入////////////////////////////

将namespace改为import引入类,index.html直接引入ts文件,免执行编译命令,自动监听保存后自动刷新页面。

ts6

///////ts6////////////////////////////

改变视口:gl.viewport(-1, 1, 1, -1);

vite-typescript-webgl's People

Contributors

wlii 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.