Skip to content

Commit

Permalink
Merge branch 'master' of github.com:playcanvas/engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Glidias committed Jul 15, 2019
2 parents bf0c11d + 32861fb commit c99e404
Show file tree
Hide file tree
Showing 355 changed files with 44,723 additions and 22,787 deletions.
47 changes: 47 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
version: 2
jobs:
build:
docker:
- image: circleci/openjdk@sha256:0405d443a664898c7b59f97b4cfebbe8d369370b2edf4f82b8fc1945bdd3b2e0

working_directory: ~/repo

steps:
- checkout

- run:
name: update-npm
command: 'sudo npm install -g npm@latest'

- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}

- run:
name: install-npm
command: npm install

- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules

- run:
name: build
command: npm run build

- run:
name: test-source
command: npm run test

- run:
name: test-release
command: npm run test:release

- run:
name: lint
command: npm run lint


40 changes: 32 additions & 8 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,49 @@ graph-node.js

## Namespaces and Classes

Use library function pc.extend to add additional Classes, methods and variables on to an existing namespace.
Private functions and variables should be declared inside the namespace.
Avoid declaring multiple Classes and Methods extending namespace per file.
The entire PlayCanvas API must be declared under the ```pc``` namespace. The vast majority of the PlayCanvas codebase is made up of 'class' definitions. These have the following structure (which should be adhered to):

```javascript
pc.extend(pc, function() {
Object.assign(pc, function() {
// Closure to define new class

var Class = function () {
};

Object.assign(Class.prototype, {
someFunc: function () {

}
});

return {
Class: Class
};
}());
```

// optionally can inherit
Class = pc.inherits(Class, pc.Base);
You can also subclass existing classes:

Class.prototype.derivedFn = function () {
```javascript
Object.assign(pc, function() {
// Closure to define new class

var SubClass = function () {
pc.SuperClass.call(this);
};

// optionally can inherit
SubClass.prototype = Object.create(pc.SuperClass.prototype);
SubClass.prototype.constructor = SubClass;

Object.assign(SubClass.prototype, {
someFunc: function () {
SuperClass.prototype.someFunc.call(this);
}
});

return {
Class: Class
SubClass: SubClass
};
}());
```
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
*.DS_Store
/build/output
/build/_tmp
/src/graphics/program-lib/chunks/generated-shader-chunks.js
node_modules/
.idea/
npm-debug.log
.java-version
release.py
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Many games and apps have been published using the PlayCanvas engine. Here is a s
<br />
[![Space Base](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/12/411394/I2C48B-image-25.jpg)](https://playcanv.as/p/yipplmVO/) [![Sponza Runtime Lightmaps](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/12/391368/221DFF-image-25.jpg)](https://playcanv.as/p/txPePQvy/) [![Star-Lord](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/12/333626/BGQN9H-image-25.jpg)](https://playcanv.as/p/SA7hVBLt) [![Orange Room VR](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/12/434546/BKST60-image-25.jpg)](https://playcanv.as/p/zi09Xvld/)
<br />
[![Car](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/12/347824/7ULQ3Y-image-25.jpg)](http://car.playcanvas.com/) [![Steampunk Slots](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/23510/344862/VH0NOH-image-25.jpg)](https://playcanv.as/p/nL1dYbMv) [![Casino](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/14928/349824/U88HJQ-image-25.jpg)](http://casino.playcanvas.com/) [![Seemore](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/14705/319531/O4J4VU-image-25.jpg)](http://seemore.playcanvas.com/)
[![Car](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/12/347824/7ULQ3Y-image-25.jpg)](http://car.playcanvas.com/) [![Steampunk Slots](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/23510/344862/VH0NOH-image-25.jpg)](https://playcanv.as/p/nL1dYbMv) [![Casino](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/14928/349824/U88HJQ-image-25.jpg)](http://casino.playcanvas.com/) [![Seemore](https://s3-eu-west-1.amazonaws.com/images.playcanvas.com/projects/14705/319531/O4J4VU-image-25.jpg)](https://playcanv.as/p/MflWvdTW/)

You can see more games on the [PlayCanvas website](https://playcanvas.com/explore).

Expand Down Expand Up @@ -45,7 +45,7 @@ The PlayCanvas Engine is a fully featured game engine.
* **Resource Loading**
* Simple and powerful resource loading
* Streaming of individual assets
* Asset Variants - loads compressed textures (DXT, PVR, ETC1) based on platform support
* Asset Variants - loads compressed textures (DXT, PVR, ETC1, ETC2) based on platform support
* **Entity / Component System**
* Built-in components: model, sound, animation, camera, collision, light, rigidbody, script, particlesystem
* **Scripting system**
Expand Down Expand Up @@ -179,6 +179,25 @@ Specific engine versions:
* https://code.playcanvas.com/playcanvas-0.181.11.js
* https://code.playcanvas.com/playcanvas-0.181.11.min.js

## How to run tests

PlayCanvas makes use of Karma for running unit tests, and provides three test ways of executing them depending on what phase of development you're in:

# Runs the tests once over the unbuilt source files - useful if you just want a quick 'all-clear'
npm run test

# Watches all source and test files for changes, and automatically re-runs the tests when they change.
# Open http://localhost:9876/debug.html in your browser to debug the tests in real time.
#
# You can also edit the `tests/**/test_*.js` glob in tests/karma.conf.js to run a subset of the tests,
# during development.
npm run test:watch

# Runs the tests once over playcanvas-latest.js - mainly used by CI, but sometimes useful if you want
# to test the engine after building it. Make sure to do `npm run build` first to make sure you have
# an up-to-date build.
npm run test:release

## Getting Help

[**Forums**](https://forum.playcanvas.com) - Use the forum to ask/answer questions about PlayCanvas.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0-dev
1.22.0-dev
65 changes: 59 additions & 6 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ try {

var DEFAULT_OUTPUT = "output/playcanvas-latest.js";
var DEFAULT_TEMP = "_tmp";
var DEFAULT_SOURCE = "../src";
var SRC_DIR = "../";

var COMPILER_LEVEL = [
Expand All @@ -48,7 +49,9 @@ var COMPILER_LEVEL = [

var debug = false;
var profiler = false;
var sourceMap = false;
var outputPath = DEFAULT_OUTPUT;
var sourcePath = DEFAULT_SOURCE;
var tempPath = DEFAULT_TEMP;
var compilerLevel = COMPILER_LEVEL[0];
var formattingLevel = undefined;
Expand Down Expand Up @@ -158,11 +161,15 @@ var preprocess = function (dependencies) {
var buffer = fs.readFileSync(filepath);

var pp = new Preprocessor(buffer.toString());
var src = pp.process({
PROFILER: profiler || debug,
DEBUG: debug
});

var src;
// TODO: source mapped build doesn't support preprocessor yet
if(this.sourceMap)
src = buffer;
else
src = pp.process({
PROFILER: profiler || debug,
DEBUG: debug
});
var dir = path.dirname(_out);
fse.ensureDirSync(dir);

Expand All @@ -174,6 +181,24 @@ var preprocess = function (dependencies) {
return dependenciesOut;
};

var getCopyrightNotice = function (ver, rev) {
var buildOptions = "";
if (debug || profiler) {
if (profiler && !debug) {
buildOptions += " (PROFILER)";
} else if (debug) {
buildOptions += " (DEBUG PROFILER)";
}
}
return [
"/*",
" * PlayCanvas Engine v" + ver + " revision " + rev + buildOptions,
" * Copyright 2011-" + new Date().getFullYear() + " PlayCanvas Ltd. All rights reserved.",
" */",
""
].join("\n");
};

// insert version and revision into output source file
var insertVersions = function (filepath, callback) {
getRevision(function (err, rev) {
Expand All @@ -185,6 +210,7 @@ var insertVersions = function (filepath, callback) {

var content = buffer.toString();

content = getCopyrightNotice(ver, rev) + content;
content = replaceAll(content, "__CURRENT_SDK_VERSION__", ver);
content = replaceAll(content, "__REVISION__", rev);

Expand Down Expand Up @@ -234,6 +260,25 @@ var run = function () {
if (compilerLevel === "WHITESPACE_ONLY") {
options.formatting = "pretty_print";
}

if(sourceMap) {
var outputfilename = path.basename(outputPath);

var wrapperContent = fs.readFileSync("./umd-wrapper.js");
var wrapperPostamble = "\n//# sourceMappingURL=" + outputfilename + ".map";

var tempWrapperPath = path.join(tempPath, "./_umd-wrapper.js");
fs.writeFileSync(tempWrapperPath, wrapperContent + wrapperPostamble);

var mapFilePath = outputPath + ".map";
var relativeSourcePath = path.relative(path.dirname(outputPath), sourcePath);

options.output_wrapper_file = tempWrapperPath;
options.create_source_map = mapFilePath;
options.source_map_location_mapping = "_tmp/src|" + relativeSourcePath;
options.source_map_include_content = undefined;
}

var closureCompiler = new ClosureCompiler(options);

// compile
Expand Down Expand Up @@ -275,7 +320,7 @@ var arguments = function () {
process.argv.forEach(function (arg) {
if (arg === '-h') {
console.log("Build Script for PlayCanvas Engine\n");
console.log("Usage: node build.js -l [COMPILER_LEVEL] -o [OUTPUT_PATH]\n");
console.log("Usage: node build.js -l [COMPILER_LEVEL] -o [OUTPUT_PATH] -m [SOURCE_PATH]\n");
console.log("Arguments:");
console.log("-h: show this help");
console.log("-l COMPILER_LEVEL: Set compiler level");
Expand All @@ -285,6 +330,7 @@ var arguments = function () {
console.log("-o PATH: output file path [output/playcanvas-latest.js]");
console.log("-d: build debug engine configuration");
console.log("-p: build profiler engine configuration");
console.log("-m SOURCE_PATH: build engine and generate source map next to output file. [../src]");
process.exit();
}

Expand All @@ -309,6 +355,13 @@ var arguments = function () {
outputPath = arg;
}

if (arg === '-m') {
sourceMap = true;
}

if (_last === '-m' && !arg.startsWith('-')) {
sourcePath = arg;
}
_last = arg;
});
};
Expand Down
Loading

0 comments on commit c99e404

Please sign in to comment.