Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umd package can provide es5? #22025

Closed
deyihu opened this issue Jun 19, 2021 · 3 comments
Closed

umd package can provide es5? #22025

deyihu opened this issue Jun 19, 2021 · 3 comments

Comments

@deyihu
Copy link

deyihu commented Jun 19, 2021

Is your feature request related to a problem? Please describe.
The current UMD package is ES6. If my code is Es5, I can't inherit three related classes

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/**
 * @author WestLangley / http://github.com/WestLangley
 *
 */
import * as THREE from 'three';
import LineSegmentsGeometry from './LineSegmentsGeometry';
import { addAttribute } from '../ThreeAdaptUtil';
import LineMaterial from './LineMaterial';
var LineSegments2 = /** @class */ (function (_super) {
    __extends(LineSegments2, _super);
    function LineSegments2(geometry, material) {
        var _this = _super.call(this, geometry, material) || this;
        _this.isLineSegments2 = true;
        _this.type = 'LineSegments2';
        _this.geometry = geometry !== undefined ? geometry : new LineSegmentsGeometry();
        _this.material = material !== undefined ? material : new LineMaterial({ color: Math.random() * 0xffffff });
        return _this;
    }
    LineSegments2.prototype.computeLineDistances = function () {
        var start = new THREE.Vector3();
        var end = new THREE.Vector3();
        var geometry = this.geometry;
        var instanceStart = geometry.attributes.instanceStart;
        var instanceEnd = geometry.attributes.instanceEnd;
        var lineDistances = new Float32Array(2 * instanceStart.data.count);
        for (var i = 0, j = 0, l = instanceStart.data.count; i < l; i++, j += 2) {
            start.fromBufferAttribute(instanceStart, i);
            end.fromBufferAttribute(instanceEnd, i);
            lineDistances[j] = (j === 0) ? 0 : lineDistances[j - 1];
            lineDistances[j + 1] = lineDistances[j] + start.distanceTo(end);
        }
        var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer(lineDistances, 2, 1); // d0, d1
        addAttribute(geometry, 'instanceDistanceStart', new THREE.InterleavedBufferAttribute(instanceDistanceBuffer, 1, 0));
        addAttribute(geometry, 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute(instanceDistanceBuffer, 1, 1));
        // geometry.addAttribute('instanceDistanceStart', new THREE.InterleavedBufferAttribute(instanceDistanceBuffer, 1, 0)); // d0
        // geometry.addAttribute('instanceDistanceEnd', new THREE.InterleavedBufferAttribute(instanceDistanceBuffer, 1, 1)); // d1
        return this;
    };
    // eslint-disable-next-line no-unused-vars
    LineSegments2.prototype.copy = function (source) {
        // todo
        return this;
    };
    return LineSegments2;
}(THREE.Mesh));
;
// LineSegments2.prototype = Object.assign(Object.create(THREE.Mesh.prototype), {
//     constructor: LineSegments2,
//     isLineSegments2: true,
// });
export default LineSegments2;
//# sourceMappingURL=LineSegments2.js.map

https://cdn.jsdelivr.net/npm/three@0.129.0/build/three.js

$TOEZ@480C7EZ4N@___92)J

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

umd package Use Es5 version, The ESM package can use ES6

A clear and concise description of what you want to happen.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

@mrdoob
Copy link
Owner

mrdoob commented Jun 19, 2021

If you need a ES5 build you can change this line to "targets": ">0.25%" and run npm run build.

@deyihu
Copy link
Author

deyihu commented Jun 19, 2021

If you need a ES5 build you can change this line to "targets": ">0.25%" and run npm run build.

Yes, I can compile it myself, but CDN will not be used because my NPM package is Es5

@mrdoob
Copy link
Owner

mrdoob commented Jun 19, 2021

Sorry, we deprecated ES5 support. You'll have to update your code or continue using a previous version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants