├── src ├── Building.ts ├── typings.d.ts ├── App.ts ├── City.ts └── index.ts ├── style.css ├── index.html ├── .editorconfig ├── tsconfig.json ├── docs ├── development.md └── test.html ├── .gitignore ├── README.md ├── package.json ├── webpack.config.js ├── .github └── workflows │ └── deploy.yml ├── public └── coco.fixtures.json └── LICENSE /src/Building.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | /* Styles go here. */ 2 | 3 | html, 4 | body { 5 | margin: 0; 6 | padding: 0; 7 | } 8 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Codecity 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | # 使用单引号 11 | quote_type = single 12 | 13 | [*.md] 14 | max_line_length = off 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "experimentalDecorators": true, 7 | "emitDecoratorMetadata": true, 8 | "preserveConstEnums": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "outDir": "./lib/", 11 | "sourceMap": true 12 | }, 13 | "exclude": [ 14 | "node_modules", 15 | "lib" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /docs/development.md: -------------------------------------------------------------------------------- 1 | # Development 2 | 3 | 4 | ## Setup 5 | 6 | ## FontFace 7 | 8 | [http://gero3.github.io/facetype.js/](http://gero3.github.io/facetype.js/) 9 | 10 | ## Browser Plugins 11 | 12 | ### WebXR 13 | 14 | https://github.com/MozillaReality/WebXR-emulator-extension 15 | 16 | plugins: https://addons.mozilla.org/en-US/firefox/addon/webxr-api-emulator/ 17 | 18 | ## 19 | 20 | https://addons.mozilla.org/en-US/firefox/addon/three-js-developer-tools/ 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | node_modules 28 | 29 | # Optional npm cache directory 30 | .npm 31 | 32 | # Optional REPL history 33 | .node_repl_history 34 | 35 | # Dist and OSX 36 | dist 37 | lib 38 | .DS_Store 39 | 40 | # Lock 41 | yarn.lock 42 | package-lock.json 43 | 44 | # awesome-typescript 45 | .awcache 46 | .idea 47 | samples 48 | public/data.json 49 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | interface FlareTreeNode { 2 | name: String, 3 | children: FlareTreeNode[], 4 | data: { 5 | loc: LanguageLocData, 6 | git: GitData 7 | } 8 | } 9 | 10 | interface GitData { 11 | last_update: number, 12 | age_in_days: number, 13 | creation_date: number, 14 | user_count: number, 15 | users: number[], // dictionary IDs 16 | details: GitDetails[], 17 | } 18 | 19 | interface GitDetails { 20 | commit_day: number, 21 | users: number[], 22 | commits: number, 23 | lines_added: number, 24 | lines_deleted: number, 25 | } 26 | 27 | interface LanguageLocData { 28 | language: String, 29 | binary: Boolean, 30 | blanks: number, 31 | code: number, 32 | comments: number, 33 | lines: number, 34 | bytes: number, 35 | } 36 | 37 | interface ClocSummary { 38 | language: String, 39 | blanks: String, 40 | code: String, 41 | comments: String, 42 | reports: ClocDetail[], 43 | } 44 | 45 | interface ClocDetail { 46 | blanks: number, 47 | code: number, 48 | comments: number, 49 | file_name: String, 50 | path: String, 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Codecity 2 | 3 | > codecity is a code explorer in metaverase for fun. 4 | 5 | Codecity 是一个用于在元宇宙中进行遗留系统分析的工具。 6 | 7 | Todo for VR PoC: 8 | 9 | - [x] render city with Three.js 10 | - [x] code render 11 | - [ ] code explorer with city 12 | - [ ] interactive 13 | - [ ] tooltip 14 | - [ ] support for XR devices 15 | - [ ] Oculus Quest 2 16 | - [ ] others 17 | 18 | Todo for Real world: 19 | 20 | - [ ] code analysis integration 21 | - [ ] show struct 22 | - [ ] show callee 23 | - [ ] multiple repo support 24 | 25 | ## Document 26 | 27 | setup: 28 | 29 | install WebVR extension: 30 | 31 | - Chrome: [WebXR API Emulator](https://chrome.google.com/webstore/detail/webxr-api-emulator/mjddjgeghkdijejnciaefnkjmkafnnje) 32 | 33 | guide: 34 | 35 | - [Using VR controllers and locomotion in THREE.js](https://ada.is/blog/2020/05/18/using-vr-controllers-and-locomotion-in-threejs/) Left Controller 位置控制 Hand pos 36 | 37 | code refs: 38 | 39 | - [http://colordodge.com/ProceduralCity/](http://colordodge.com/ProceduralCity/) 40 | - [https://observablehq.com/@analyzer2004/3d-treemap](https://observablehq.com/@analyzer2004/3d-treemap) 41 | 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "three-typescript-starter", 3 | "version": "1.0.0", 4 | "description": "three.js + typescript", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "webpack serve --open", 9 | "build": "webpack build" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/phodal/codexity.git" 14 | }, 15 | "keywords": [], 16 | "author": "Phodal HUANG", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/phodal/codexity/issues" 20 | }, 21 | "homepage": "https://github.com/phodal/codexity#readme", 22 | "devDependencies": { 23 | "@types/three": "^0.134.0", 24 | "copy-webpack-plugin": "^9.0.1", 25 | "css-loader": "latest", 26 | "html-webpack-plugin": "latest", 27 | "progress-bar-webpack-plugin": "latest", 28 | "style-loader": "latest", 29 | "ts-loader": "latest", 30 | "typescript": "latest", 31 | "webpack": "latest", 32 | "webpack-cli": "latest", 33 | "webpack-dev-server": "latest" 34 | }, 35 | "dependencies": { 36 | "@types/d3": "^7.1.0", 37 | "cannon": "^0.6.2", 38 | "d3": "^7.1.1", 39 | "stats.js": "^0.17.0", 40 | "three": "latest" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /docs/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Quantize scale 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path'); 2 | 3 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | const ProgressBarPlugin = require('progress-bar-webpack-plugin'); 5 | const CopyPlugin = require("copy-webpack-plugin"); 6 | 7 | module.exports = { 8 | mode: 'development', 9 | 10 | entry: './src/index.ts', 11 | output: { 12 | filename: 'bundle.js', 13 | path: resolve(__dirname, 'dist'), 14 | }, 15 | devServer: { 16 | static: { 17 | directory: resolve(__dirname, 'public'), 18 | }, 19 | compress: true, 20 | port: 9000, 21 | }, 22 | resolve: { 23 | extensions: ['.ts', '.tsx', '.js', '.jsx'], 24 | }, 25 | 26 | devtool: 'source-map', 27 | 28 | module: { 29 | rules: [ 30 | { 31 | test: /\.tsx?$/, 32 | use: ['ts-loader'], 33 | }, 34 | { 35 | test: /\.(jpe?g|png|gif|svg)$/i, 36 | use: [ 37 | 'file-loader?hash=sha512&digest=hex&name=images/[hash].[ext]', 38 | 'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false', 39 | ], 40 | }, 41 | { 42 | test: /\.css$/i, 43 | use: ['style-loader', 'css-loader'], 44 | }, 45 | ], 46 | }, 47 | resolve: { 48 | extensions: ['.ts', '.tsx', '.js', '.jsx'], 49 | }, 50 | plugins: [ 51 | new ProgressBarPlugin(), 52 | new CopyPlugin({ 53 | patterns: [ 54 | { from: "public", to: "" }, 55 | ], 56 | }), 57 | new HtmlWebpackPlugin({ 58 | template: `${__dirname}/index.html`, 59 | filename: 'index.html', 60 | inject: 'body', 61 | }), 62 | ], 63 | }; 64 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Deploy 4 | 5 | # Controls when the action will run. Triggers the workflow on push or pull request 6 | # events but only for the master branch 7 | on: 8 | push: 9 | branches: [master] 10 | 11 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 12 | jobs: 13 | # This workflow contains a single job called "build" 14 | build: 15 | # The type of runner that the job will run on 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly. 21 | with: 22 | persist-credentials: false 23 | 24 | - name: Use Node.js 12.x 25 | uses: actions/setup-node@v1 26 | with: 27 | node-version: "12.x" 28 | 29 | - name: Get yarn cache directory path 30 | id: yarn-cache-dir-path 31 | run: echo "::set-output name=dir::$(yarn cache dir)" 32 | 33 | - uses: actions/cache@v1 34 | id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) 35 | with: 36 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 37 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 38 | restore-keys: | 39 | ${{ runner.os }}-yarn- 40 | 41 | - name: Install 42 | run: | 43 | yarn install 44 | 45 | - name: Build 46 | run: | 47 | yarn build 48 | 49 | - name: Deploy 🚀 50 | uses: JamesIves/github-pages-deploy-action@4.1.5 51 | with: 52 | branch: gh-pages # The branch the action should deploy to. 53 | folder: dist # The folder the action should deploy. 54 | -------------------------------------------------------------------------------- /src/App.ts: -------------------------------------------------------------------------------- 1 | import * as THREE from 'three'; 2 | import {PerspectiveCamera, Scene, WebGLRenderer} from 'three'; 3 | import {OrbitControls} from "three/examples/jsm/controls/OrbitControls"; 4 | import * as Stats from "stats.js"; 5 | import {Font} from "three/examples/jsm/loaders/FontLoader"; 6 | 7 | export class App { 8 | static isDebug: boolean = false; 9 | static stats: Stats; 10 | static container: HTMLElement; 11 | static scene: Scene; 12 | static camera: PerspectiveCamera; 13 | static controls: OrbitControls; 14 | // x 15 | static height = 600; 16 | // z 17 | static width = 1800; 18 | // y 19 | static depth = 1000; 20 | 21 | static renderer: WebGLRenderer; 22 | static font: Font; 23 | static config = { 24 | fontSize: 10 25 | } 26 | 27 | constructor() { 28 | } 29 | 30 | static createRender() { 31 | let renderer = new THREE.WebGLRenderer({antialias: true}); 32 | renderer.setPixelRatio(window.devicePixelRatio); 33 | renderer.setSize(window.innerWidth, window.innerHeight); 34 | renderer.outputEncoding = THREE.sRGBEncoding; 35 | renderer.shadowMap.enabled = true; 36 | renderer.xr.enabled = true; 37 | renderer.xr.setReferenceSpaceType( 'local' ); 38 | renderer.xr.addEventListener( 'sessionstart', function ( event ) { 39 | App.controls.enabled = false; 40 | } ); 41 | 42 | renderer.xr.addEventListener( 'sessionend', function ( event ) { 43 | App.controls.enabled = true; 44 | } ); 45 | 46 | App.renderer = renderer; 47 | 48 | App.container.appendChild(renderer.domElement); 49 | } 50 | 51 | static createStats() { 52 | App.stats = new Stats(); 53 | App.stats.showPanel(0); 54 | 55 | document.body.appendChild(App.stats.dom); 56 | } 57 | 58 | static createControls() { 59 | App.controls = new OrbitControls(App.camera, App.container); 60 | App.controls.enableDamping = true; 61 | App.controls.dampingFactor = 0.25; 62 | App.controls.enableZoom = true; 63 | App.controls.target.set(0, 0, 0); 64 | App.controls.update(); 65 | } 66 | 67 | static debugPoint(x, y, z) { 68 | const geometry = new THREE.SphereGeometry( 15, 32, 16 ); 69 | const material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); 70 | const sphere = new THREE.Mesh( geometry, material ); 71 | sphere.position.set(x, y, z); 72 | App.scene.add( sphere ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /public/coco.fixtures.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "language": "Java", 4 | "blanks": 135, 5 | "code": 564, 6 | "comments": 723, 7 | "reports": [ 8 | { 9 | "blanks": 2, 10 | "code": 4, 11 | "comments": 19, 12 | "file_name": "SubscriberExceptionHandler.java", 13 | "path": "guava/SubscriberExceptionHandler.java" 14 | }, 15 | { 16 | "blanks": 3, 17 | "code": 10, 18 | "comments": 22, 19 | "file_name": "AllowConcurrentEvents.java", 20 | "path": "guava/AllowConcurrentEvents.java" 21 | }, 22 | { 23 | "blanks": 3, 24 | "code": 10, 25 | "comments": 27, 26 | "file_name": "Subscribe.java", 27 | "path": "guava/Subscribe.java" 28 | }, 29 | { 30 | "blanks": 9, 31 | "code": 28, 32 | "comments": 32, 33 | "file_name": "SubscriberExceptionContext.java", 34 | "path": "guava/SubscriberExceptionContext.java" 35 | }, 36 | { 37 | "blanks": 9, 38 | "code": 23, 39 | "comments": 40, 40 | "file_name": "DeadEvent.java", 41 | "path": "guava/DeadEvent.java" 42 | }, 43 | { 44 | "blanks": 6, 45 | "code": 15, 46 | "comments": 43, 47 | "file_name": "AsyncEventBus.java", 48 | "path": "guava/AsyncEventBus.java" 49 | }, 50 | { 51 | "blanks": 20, 52 | "code": 84, 53 | "comments": 44, 54 | "file_name": "Subscriber.java", 55 | "path": "guava/Subscriber.java" 56 | }, 57 | { 58 | "blanks": 34, 59 | "code": 181, 60 | "comments": 54, 61 | "file_name": "SubscriberRegistry.java", 62 | "path": "guava/SubscriberRegistry.java" 63 | }, 64 | { 65 | "blanks": 25, 66 | "code": 96, 67 | "comments": 69, 68 | "file_name": "Dispatcher.java", 69 | "path": "guava/Dispatcher.java" 70 | }, 71 | { 72 | "blanks": 22, 73 | "code": 108, 74 | "comments": 123, 75 | "file_name": "EventBus.java", 76 | "path": "guava/EventBus.java" 77 | }, 78 | { 79 | "blanks": 2, 80 | "code": 5, 81 | "comments": 250, 82 | "file_name": "package-info.java", 83 | "path": "guava/package-info.java" 84 | } 85 | ] 86 | }, 87 | { 88 | "language": "Markdown", 89 | "blanks": 1, 90 | "code": 0, 91 | "comments": 4, 92 | "reports": [ 93 | { 94 | "blanks": 1, 95 | "code": 0, 96 | "comments": 4, 97 | "file_name": "README.md", 98 | "path": "README.md" 99 | } 100 | ] 101 | }, 102 | { 103 | "language": "Rust", 104 | "blanks": 0, 105 | "code": 0, 106 | "comments": 0, 107 | "reports": [ 108 | { 109 | "blanks": 0, 110 | "code": 0, 111 | "comments": 0, 112 | "file_name": "main.rs", 113 | "path": "src/main.rs" 114 | } 115 | ] 116 | } 117 | ] -------------------------------------------------------------------------------- /src/City.ts: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import * as d3 from "d3"; 3 | import {App} from "./App"; 4 | import {TextGeometry} from "three/examples/jsm/geometries/TextGeometry"; 5 | import {BoxLineGeometry} from "three/examples/jsm/geometries/BoxLineGeometry"; 6 | 7 | let CityInfo = { 8 | maxLines: 0, 9 | maxChanges: 0, 10 | pool: undefined 11 | } 12 | 13 | function treemap(data) { 14 | let root = d3.treemap() 15 | .size([App.width, App.height]) 16 | .paddingOuter(5) 17 | .paddingInner(5) 18 | .paddingTop(20) 19 | .round(true) 20 | (d3.hierarchy(data) 21 | .sum(d => { 22 | d.value = d.data?.loc?.lines 23 | d.changes = d.data?.git?.details?.length ? d.data?.git?.details?.length : 0; 24 | 25 | if (CityInfo.maxLines < (d as any).value) { 26 | CityInfo.maxLines = (d as any).value 27 | } 28 | if (CityInfo.maxChanges < d.changes) { 29 | CityInfo.maxChanges = d.changes 30 | } 31 | return d.value 32 | }) 33 | .sort((a, b) => b.value - a.value)) 34 | 35 | return Array.from(d3.group(root, d => d.height)); 36 | } 37 | 38 | function loadData(): Promise { 39 | return d3.json("data.json") 40 | } 41 | 42 | function addCuboid(w, h, d, x, y, z, color, scene, node) { 43 | let color1 = CityInfo.pool.colors(node.data.changes); 44 | let meshBasicMaterial = new THREE.MeshLambertMaterial({ 45 | color: color1, 46 | opacity: 0.9, 47 | transparent: true 48 | }); 49 | 50 | const geometry = new THREE.BoxBufferGeometry(w, h + node.data.changes * 2, d); 51 | 52 | const cuboid = new THREE.Mesh(geometry, meshBasicMaterial); 53 | cuboid.position.set(x + w / 2, y, z + d / 2); 54 | cuboid.receiveShadow = true; 55 | cuboid.castShadow = true; 56 | 57 | let edgesGeometry = new THREE.EdgesGeometry(geometry); 58 | let lineBasicMaterial = new THREE.LineBasicMaterial({ 59 | color: d3.color(color1).darker(0.5).formatHex(), 60 | linewidth: 1 61 | }); 62 | const frame = new THREE.LineSegments(edgesGeometry, lineBasicMaterial); 63 | cuboid.add(frame); 64 | 65 | scene.add(cuboid); 66 | return cuboid; 67 | } 68 | 69 | function createpool(chartData) { 70 | const color = d3.scaleSequential([8, 0], d3.interpolateMagma); 71 | const geometry = new THREE.BoxBufferGeometry(1, 1, 1), 72 | colors = chartData.map(layer => color(layer[0])); 73 | 74 | const change_colors = d3.scaleQuantize() 75 | .domain([0, CityInfo.maxChanges]) 76 | .range(["#5E4FA2", "#3288BD", "#66C2A5", "#ABDDA4", "#E6F598", 77 | "#FFFFBF", "#FEE08B", "#FDAE61", "#F46D43", "#D53E4F", "#9E0142"] as any); 78 | 79 | return { 80 | colors: change_colors, 81 | geometry, 82 | materials: colors.map(color => new THREE.MeshBasicMaterial({ 83 | color, 84 | opacity: 0.9, 85 | transparent: true 86 | })), 87 | edgeGeometry: new THREE.EdgesGeometry(geometry), 88 | lineMaterials: colors.map(color => new THREE.LineBasicMaterial({ 89 | color: d3.color(color).darker(0.5).formatHex(), 90 | linewidth: 1 91 | })), 92 | textMaterial: new THREE.MeshBasicMaterial({color: 0x333333}) 93 | } 94 | 95 | } 96 | 97 | export function createCity() { 98 | return loadData().then((data) => { 99 | let buildings = treemap(data); 100 | 101 | CityInfo.pool = createpool(buildings); 102 | 103 | const city = new THREE.LineSegments( 104 | new BoxLineGeometry(10, 10, 10, 10, 10, 10).translate(0, 0, 0), 105 | new THREE.LineBasicMaterial({color: 0x808080}) 106 | ); 107 | 108 | city.position.set(-App.width / 2, 0, -App.height / 2) 109 | 110 | buildings.forEach(layer => layer[1].forEach((node: any) => { 111 | const h = 6, hh = h / 2, 112 | w = node.x1 - node.x0, 113 | d = node.y1 - node.y0, 114 | cl = buildings.length - node.height - 1; 115 | const format = d3.format(",d"), 116 | tolerance = 0.6; 117 | 118 | function estimate(text) { 119 | return text.length * App.config.fontSize * tolerance; 120 | } 121 | 122 | const cuboid = addCuboid(w, h, d, node.x0, cl * h, node.y0, cl, city, node); 123 | const rx = Math.PI * 1.5; 124 | 125 | let height_offset = node.data.changes > hh ? node.data.changes + hh : hh; 126 | 127 | if (node.children) { 128 | let label = `${node.data.name} ${format(node.value)}`; 129 | if (estimate(label) > w) label = node.data.name; 130 | if (estimate(label) < w) { 131 | let mesh = addText(label, App.config.fontSize, 0.3, node.x0 + 2, cl * h + height_offset, node.y0 + 12, rx, 0, 0, node); 132 | city.add(mesh); 133 | } 134 | } else { 135 | const labels = node.data.name.split(/(?=[A-Z][^A-Z])/g).concat(`${format(node.value)}, ${format(node.data.changes)}`), 136 | max = Math.max(...labels.map(label => label.length * App.config.fontSize * tolerance)); 137 | 138 | if (max < w) { 139 | if (labels.length * App.config.fontSize > d) labels.pop(); 140 | if (labels.length * App.config.fontSize < d) { 141 | labels.forEach((label, i) => { 142 | let mesh = addText(label, App.config.fontSize, 0.3, node.x0 + 2, cl * h + height_offset, node.y0 + (i * 12) + 12, rx, 0, 0, node); 143 | city.add(mesh); 144 | }); 145 | } 146 | } 147 | } 148 | })) 149 | 150 | App.scene.add(city) 151 | }); 152 | } 153 | 154 | function addText(text, size, h, x, y, z, rx, ry, rz, node) { 155 | const geometry = new TextGeometry(text, {font: App.font, size, height: h}); 156 | geometry.computeBoundingSphere(); 157 | geometry.computeVertexNormals(); 158 | 159 | const mesh = new THREE.Mesh(geometry, CityInfo.pool.textMaterial); 160 | mesh.position.set(x, y, z); 161 | mesh.rotation.set(rx, ry, rz); 162 | 163 | return mesh; 164 | } 165 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import "../style.css" 2 | import * as THREE from 'three'; 3 | import {VRButton} from 'three/examples/jsm/webxr/VRButton.js'; 4 | import {XRControllerModelFactory} from 'three/examples/jsm/webxr/XRControllerModelFactory.js'; 5 | import {XRHandModelFactory} from 'three/examples/jsm/webxr/XRHandModelFactory.js'; 6 | import {FontLoader} from "three/examples/jsm/loaders/FontLoader"; 7 | 8 | import {createCity} from "./City"; 9 | import {App} from "./App"; 10 | 11 | let hand1, hand2; 12 | let controller1, controller2; 13 | let controllerGrip1, controllerGrip2; 14 | 15 | const tmpVector1 = new THREE.Vector3(); 16 | const tmpVector2 = new THREE.Vector3(); 17 | 18 | let grabbing = false; 19 | const scaling = { 20 | active: false, 21 | initialDistance: 0, 22 | object: null, 23 | initialScale: 1 24 | }; 25 | 26 | const spheres = []; 27 | 28 | init(); 29 | animate(); 30 | 31 | function createControllers() { 32 | function onSelectStart() { 33 | console.log("onSelectStart"); 34 | } 35 | 36 | function onSelectEnd() { 37 | console.log("onSelectEnd"); 38 | } 39 | 40 | function buildController( data ) { 41 | let geometry, material; 42 | switch ( data.targetRayMode ) { 43 | case 'tracked-pointer': 44 | geometry = new THREE.BufferGeometry(); 45 | geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 0, 0, - 1 ], 3 ) ); 46 | geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( [ 0.5, 0.5, 0.5, 0, 0, 0 ], 3 ) ); 47 | 48 | material = new THREE.LineBasicMaterial( { vertexColors: true, blending: THREE.AdditiveBlending } ); 49 | return new THREE.Line( geometry, material ); 50 | 51 | case 'gaze': 52 | geometry = new THREE.RingGeometry( 0.02, 0.04, 32 ).translate( 0, 0, - 1 ); 53 | material = new THREE.MeshBasicMaterial( { opacity: 0.5, transparent: true } ); 54 | return new THREE.Mesh( geometry, material ); 55 | } 56 | } 57 | 58 | controller1 = App.renderer.xr.getController(0); 59 | controller1.addEventListener( 'selectstart', onSelectStart ); 60 | controller1.addEventListener( 'selectend', onSelectEnd ); 61 | controller1.addEventListener( 'connected', function ( event ) { 62 | this.add( buildController( event.data ) ); 63 | }); 64 | controller1.addEventListener( 'disconnected', function () { 65 | this.remove( this.children[ 0 ] ); 66 | } ); 67 | 68 | App.scene.add(controller1); 69 | 70 | controller2 = App.renderer.xr.getController(1); 71 | App.scene.add(controller2); 72 | 73 | // The XRControllerModelFactory will automatically fetch controller models 74 | // that match what the user is holding as closely as possible. The models 75 | // should be attached to the object returned from getControllerGrip in 76 | // order to match the orientation of the held device. 77 | 78 | const controllerModelFactory = new XRControllerModelFactory(); 79 | 80 | controllerGrip1 = App.renderer.xr.getControllerGrip( 0 ); 81 | controllerGrip1.add( controllerModelFactory.createControllerModel( controllerGrip1 ) ); 82 | App.scene.add( controllerGrip1 ); 83 | 84 | controllerGrip2 = App.renderer.xr.getControllerGrip( 1 ); 85 | controllerGrip2.add( controllerModelFactory.createControllerModel( controllerGrip2 ) ); 86 | App.scene.add( controllerGrip2 ); 87 | } 88 | 89 | function createLights() { 90 | const light = new THREE.DirectionalLight(0xffff00, 0.8); 91 | light.position.set(App.width / 2, App.depth / 2, App.height / 2); 92 | light.castShadow = true; 93 | light.shadow.mapSize.set(4096, 4096); 94 | App.scene.add(light); 95 | 96 | if (App.isDebug) { 97 | const base = new THREE.CameraHelper(light.shadow.camera); 98 | App.scene.add(base); 99 | } 100 | 101 | const dlight = new THREE.SpotLight(0xffffff); 102 | dlight.castShadow = true; 103 | dlight.position.set(App.width / 2, App.depth, App.height / 2); 104 | App.scene.add(dlight); 105 | 106 | dlight.shadow.mapSize.set(4096, 4096); 107 | dlight.shadow.camera.near = 0.5; 108 | dlight.shadow.camera.far = 2400; 109 | dlight.shadow.focus = 1; 110 | 111 | if (App.isDebug) { 112 | const helper = new THREE.CameraHelper(dlight.shadow.camera); 113 | App.scene.add(helper); 114 | } 115 | } 116 | 117 | function init() { 118 | App.container = document.createElement('div'); 119 | document.body.appendChild(App.container); 120 | 121 | App.scene = new THREE.Scene(); 122 | App.scene.background = new THREE.Color(0x444444); 123 | 124 | App.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 100000); 125 | App.camera.position.set(0, App.depth * 2, App.height); 126 | 127 | if (App.isDebug) { 128 | const axesHelper = new THREE.AxesHelper(1000); 129 | App.scene.add(axesHelper); 130 | } 131 | 132 | App.createControls(); 133 | 134 | const floorGeometry = new THREE.PlaneGeometry(App.width * 2, App.height * 2); 135 | const floorMaterial = new THREE.MeshStandardMaterial({color: 0x222222}); 136 | const floor = new THREE.Mesh(floorGeometry, floorMaterial); 137 | floor.rotation.x = -Math.PI / 2; 138 | floor.receiveShadow = true; 139 | floor.position.set(0, 0, 0); 140 | App.scene.add(floor); 141 | 142 | createLights(); 143 | 144 | const loader = new FontLoader(); 145 | loader.load('fonts/droid_sans_regular.typeface.json', function (font) { 146 | App.font = font; 147 | createCity().then(() => { 148 | 149 | }) 150 | }); 151 | 152 | App.scene.add(new THREE.HemisphereLight(0x808080, 0x606060)); 153 | 154 | App.createRender(); 155 | 156 | document.body.appendChild(VRButton.createButton(App.renderer)); 157 | 158 | createControllers(); 159 | App.createStats(); 160 | 161 | window.addEventListener('resize', onWindowResize); 162 | } 163 | 164 | 165 | function onWindowResize() { 166 | App.camera.aspect = window.innerWidth / window.innerHeight; 167 | App.camera.updateProjectionMatrix(); 168 | 169 | App.renderer.setSize(window.innerWidth, window.innerHeight); 170 | } 171 | 172 | const SphereRadius = 0.05; 173 | 174 | function onPinchStartLeft(event) { 175 | const controller = event.target; 176 | if (grabbing) { 177 | const indexTip = controller.joints['index-finger-tip']; 178 | const sphere = collideObject(indexTip); 179 | 180 | if (sphere) { 181 | const sphere2 = hand2.userData.selected; 182 | console.log("sphere1", sphere, "sphere2", sphere2); 183 | if (sphere === sphere2) { 184 | scaling.active = true; 185 | scaling.object = sphere; 186 | scaling.initialScale = sphere.scale.x; 187 | scaling.initialDistance = indexTip.position.distanceTo(hand2.joints['index-finger-tip'].position); 188 | return; 189 | } 190 | } 191 | } 192 | 193 | const geometry = new THREE.BoxGeometry(SphereRadius, SphereRadius, SphereRadius); 194 | const material = new THREE.MeshStandardMaterial({ 195 | color: Math.random() * 0xffffff, 196 | roughness: 1.0, 197 | metalness: 0.0 198 | }); 199 | const spawn = new THREE.Mesh(geometry, material); 200 | spawn.geometry.computeBoundingSphere(); 201 | 202 | const indexTip = controller.joints['index-finger-tip']; 203 | spawn.position.copy(indexTip.position); 204 | spawn.quaternion.copy(indexTip.quaternion); 205 | 206 | spheres.push(spawn); 207 | 208 | App.scene.add(spawn); 209 | } 210 | 211 | function collideObject(indexTip) { 212 | for (let i = 0; i < spheres.length; i++) { 213 | const sphere = spheres[i]; 214 | const distance = indexTip.getWorldPosition(tmpVector1).distanceTo(sphere.getWorldPosition(tmpVector2)); 215 | 216 | if (distance < sphere.geometry.boundingSphere.radius * sphere.scale.x) { 217 | return sphere; 218 | } 219 | 220 | } 221 | return null; 222 | } 223 | 224 | function onPinchStartRight(event) { 225 | const controller = event.target; 226 | const indexTip = controller.joints['index-finger-tip']; 227 | const object = collideObject(indexTip); 228 | 229 | if (object) { 230 | grabbing = true; 231 | indexTip.attach(object); 232 | controller.userData.selected = object; 233 | console.log("Selected", object); 234 | } 235 | } 236 | 237 | function onPinchEndRight(event) { 238 | const controller = event.target; 239 | 240 | if (controller.userData.selected !== undefined) { 241 | 242 | const object = controller.userData.selected; 243 | object.material.emissive.b = 0; 244 | App.scene.attach(object); 245 | 246 | controller.userData.selected = undefined; 247 | grabbing = false; 248 | 249 | } 250 | 251 | scaling.active = false; 252 | } 253 | 254 | function animate() { 255 | App.renderer.setAnimationLoop(render); 256 | } 257 | 258 | function render() { 259 | if (scaling.active) { 260 | const indexTip1Pos = hand1.joints['index-finger-tip'].position; 261 | const indexTip2Pos = hand2.joints['index-finger-tip'].position; 262 | const distance = indexTip1Pos.distanceTo(indexTip2Pos); 263 | const newScale = scaling.initialScale + distance / scaling.initialDistance - 1; 264 | scaling.object.scale.setScalar(newScale); 265 | } 266 | 267 | App.renderer.setAnimationLoop( function () { 268 | App.renderer.render( App.scene, App.camera ); 269 | } ); 270 | App.stats.update(); 271 | } 272 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | --------------------------------------------------------------------------------