larry babby and threejs for glsl

This commit is contained in:
Sam
2024-06-24 21:24:00 +12:00
parent 87d5dc634d
commit 907ebae4c0
6474 changed files with 1279596 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-present Devon Govett
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _util() {
const data = require("util");
_util = function () {
return data;
};
return data;
}
function _plugin() {
const data = require("@parcel/plugin");
_plugin = function () {
return data;
};
return data;
}
function _glslifyDeps() {
const data = _interopRequireDefault(require("glslify-deps"));
_glslifyDeps = function () {
return data;
};
return data;
}
function _glslifyBundle() {
const data = _interopRequireDefault(require("glslify-bundle"));
_glslifyBundle = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = exports.default = new (_plugin().Transformer)({
async transform({
asset,
resolve
}) {
// Parse and collect dependencies with glslify-deps
let cwd = _path().default.dirname(asset.filePath);
let depper = (0, _glslifyDeps().default)({
cwd,
resolve: async (target, opts, next) => {
try {
let filePath = await resolve(_path().default.join(opts.basedir, 'index.glsl'), target);
next(null, filePath);
} catch (err) {
next(err);
}
}
});
let ast = await (0, _util().promisify)(depper.inline.bind(depper))(await asset.getCode(), cwd);
collectDependencies(asset, ast);
// Generate the bundled glsl file
let glsl = await (0, _glslifyBundle().default)(ast);
asset.setCode(`module.exports=${JSON.stringify(glsl)};`);
asset.type = 'js';
return [asset];
}
});
function collectDependencies(asset, ast) {
for (let dep of ast) {
if (!dep.entry) {
asset.invalidateOnFileChange(dep.file);
}
}
}

View File

@@ -0,0 +1,28 @@
{
"name": "@parcel/transformer-glsl",
"version": "2.12.0",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git"
},
"main": "lib/GLSLTransformer.js",
"source": "src/GLSLTransformer.js",
"engines": {
"node": ">= 12.0.0",
"parcel": "^2.12.0"
},
"dependencies": {
"@parcel/plugin": "2.12.0",
"glslify-bundle": "^5.1.1",
"glslify-deps": "^1.3.2"
},
"gitHead": "2059029ee91e5f03a273b0954d3e629d7375f986"
}

View File

@@ -0,0 +1,51 @@
// @flow
import path from 'path';
import {promisify} from 'util';
import {Transformer} from '@parcel/plugin';
import glslifyDeps from 'glslify-deps';
import glslifyBundle from 'glslify-bundle';
export default (new Transformer({
async transform({asset, resolve}) {
// Parse and collect dependencies with glslify-deps
let cwd = path.dirname(asset.filePath);
let depper = glslifyDeps({
cwd,
resolve: async (target, opts, next) => {
try {
let filePath = await resolve(
path.join(opts.basedir, 'index.glsl'),
target,
);
next(null, filePath);
} catch (err) {
next(err);
}
},
});
let ast = await promisify(depper.inline.bind(depper))(
await asset.getCode(),
cwd,
);
collectDependencies(asset, ast);
// Generate the bundled glsl file
let glsl = await glslifyBundle(ast);
asset.setCode(`module.exports=${JSON.stringify(glsl)};`);
asset.type = 'js';
return [asset];
},
}): Transformer);
function collectDependencies(asset, ast) {
for (let dep of ast) {
if (!dep.entry) {
asset.invalidateOnFileChange(dep.file);
}
}
}