diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..0500b3a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Faraz Shaikh + +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. diff --git a/React/index.d.ts b/React/index.d.ts new file mode 100644 index 0000000..865dfaf --- /dev/null +++ b/React/index.d.ts @@ -0,0 +1,12 @@ +import { CustomShaderMaterialProps } from './types'; +import { default as CustomShaderMaterialImpl, MaterialConstructor } from '../index'; +import { Material } from 'three'; +import { AttachType } from '@react-three/fiber/dist/declarations/src/core/renderer'; + +import * as React from "react"; +declare const _default: (props: CustomShaderMaterialProps & { + ref?: React.Ref>; + attach?: AttachType; +}) => React.ReactElement; +export default _default; +export { type CustomShaderMaterialProps } from './types'; diff --git a/React/types.d.ts b/React/types.d.ts new file mode 100644 index 0000000..9854aed --- /dev/null +++ b/React/types.d.ts @@ -0,0 +1,3 @@ +import { CustomShaderMaterialParameters, MaterialConstructor } from '../types'; + +export type CustomShaderMaterialProps = CustomShaderMaterialParameters & {}; diff --git a/defaults.d.ts b/defaults.d.ts new file mode 100644 index 0000000..507029a --- /dev/null +++ b/defaults.d.ts @@ -0,0 +1,6 @@ +export declare const defaultCsmDefinitions = "\n \n#ifdef IS_VERTEX\n vec3 csm_Position;\n vec4 csm_PositionRaw;\n vec3 csm_Normal;\n\n // csm_PointSize\n #ifdef IS_POINTSMATERIAL\n float csm_PointSize;\n #endif\n#else\n vec4 csm_DiffuseColor;\n vec4 csm_FragColor;\n float csm_FragColorInfluence;\n\n // csm_Emissive, csm_Roughness, csm_Metalness\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\n vec3 csm_Emissive;\n float csm_Roughness;\n float csm_Metalness;\n float csm_Iridescence;\n \n #if defined IS_MESHPHYSICALMATERIAL\n float csm_Clearcoat;\n float csm_ClearcoatRoughness;\n vec3 csm_ClearcoatNormal;\n float csm_Transmission;\n float csm_Thickness;\n #endif\n #endif\n\n // csm_AO\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\n float csm_AO;\n #endif\n\n // csm_Bump\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \n vec3 csm_Bump;\n #endif\n\n float csm_DepthAlpha;\n#endif\n"; +export declare const defaultCsmMainDefinitions = "\n\n#ifdef IS_VERTEX\n // csm_Position & csm_PositionRaw\n #ifdef IS_UNKNOWN\n csm_Position = vec3(0.0);\n csm_PositionRaw = vec4(0.0);\n csm_Normal = vec3(0.0);\n #else\n csm_Position = position;\n csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.);\n csm_Normal = normal;\n #endif\n\n // csm_PointSize\n #ifdef IS_POINTSMATERIAL\n csm_PointSize = size;\n #endif\n#else\n csm_FragColorInfluence = 0.0;\n\n // csm_DiffuseColor & csm_FragColor\n #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHDISTANCEMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL\n csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0);\n csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\n #else\n #ifdef USE_MAP\n vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv);\n\n #ifdef DECODE_VIDEO_TEXTURE\n // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)\n _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w);\n #endif\n\n csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\n csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\n #else\n csm_DiffuseColor = vec4(diffuse, opacity);\n csm_FragColor = vec4(diffuse, opacity);\n #endif\n #endif\n\n // csm_Emissive, csm_Roughness, csm_Metalness\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\n csm_Emissive = emissive;\n csm_Roughness = roughness;\n csm_Metalness = metalness;\n\n #ifdef USE_IRIDESCENCE\n csm_Iridescence = iridescence;\n #else\n csm_Iridescence = 0.0;\n #endif\n\n #if defined IS_MESHPHYSICALMATERIAL\n #ifdef USE_CLEARCOAT\n csm_Clearcoat = clearcoat;\n csm_ClearcoatRoughness = clearcoatRoughness;\n #else\n csm_Clearcoat = 0.0;\n csm_ClearcoatRoughness = 0.0;\n #endif\n\n #ifdef USE_TRANSMISSION\n csm_Transmission = transmission;\n csm_Thickness = thickness;\n #else\n csm_Transmission = 0.0;\n csm_Thickness = 0.0;\n #endif\n #endif\n #endif\n\n // csm_AO\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\n csm_AO = 0.0;\n #endif\n\n // csm_Bump\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \n csm_Bump = vec3(0.0);\n #endif\n\n csm_DepthAlpha = 1.0;\n#endif\n"; +export declare const defaultVertDefinitions = "\n varying mat4 csm_internal_vModelViewMatrix;\n"; +export declare const defaultVertMain = "\n csm_internal_vModelViewMatrix = modelViewMatrix;\n"; +export declare const defaultFragDefinitions = "\n varying mat4 csm_internal_vModelViewMatrix;\n"; +export declare const defaultFragMain = "\n \n"; diff --git a/entry/cjs/react.cjs b/entry/cjs/react.cjs new file mode 100644 index 0000000..e29bc65 --- /dev/null +++ b/entry/cjs/react.cjs @@ -0,0 +1,26 @@ +"use strict";const Z=require("react"),ur=require("./vanilla.cjs");function sr(b){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const d in b)if(d!=="default"){const g=Object.getOwnPropertyDescriptor(b,d);Object.defineProperty(c,d,g.get?g:{enumerable:!0,get:()=>b[d]})}}return c.default=b,Object.freeze(c)}const W=sr(Z);var K={exports:{}},A={};/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Oe;function fr(){if(Oe)return A;Oe=1;var b=Z,c=Symbol.for("react.element"),d=Symbol.for("react.fragment"),g=Object.prototype.hasOwnProperty,O=b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,w={key:!0,ref:!0,__self:!0,__source:!0};function P(m,l,_){var E,y={},C=null,$=null;_!==void 0&&(C=""+_),l.key!==void 0&&(C=""+l.key),l.ref!==void 0&&($=l.ref);for(E in l)g.call(l,E)&&!w.hasOwnProperty(E)&&(y[E]=l[E]);if(m&&m.defaultProps)for(E in l=m.defaultProps,l)y[E]===void 0&&(y[E]=l[E]);return{$$typeof:c,type:m,key:C,ref:$,props:y,_owner:O.current}}return A.Fragment=d,A.jsx=P,A.jsxs=P,A}var I={};/** + * @license React + * react-jsx-runtime.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var we;function lr(){return we||(we=1,process.env.NODE_ENV!=="production"&&function(){var b=Z,c=Symbol.for("react.element"),d=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),m=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),$=Symbol.for("react.offscreen"),Q=Symbol.iterator,Pe="@@iterator";function Ce(e){if(e===null||typeof e!="object")return null;var r=Q&&e[Q]||e[Pe];return typeof r=="function"?r:null}var j=b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n=1&&f>=0&&a[s]!==p[f];)f--;for(;s>=1&&f>=0;s--,f--)if(a[s]!==p[f]){if(s!==1||f!==1)do if(s--,f--,f<0||a[s]!==p[f]){var R=` +`+a[s].replace(" at new "," at ");return e.displayName&&R.includes("")&&(R=R.replace("",e.displayName)),typeof e=="function"&&L.set(e,R),R}while(s>=1&&f>=0);break}}}finally{B=!1,V.current=u,$e(),Error.prepareStackTrace=i}var k=e?e.displayName||e.name:"",Te=k?Y(k):"";return typeof e=="function"&&L.set(e,Te),Te}function Le(e,r,t){return le(e,!1)}function Me(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function M(e,r,t){if(e==null)return"";if(typeof e=="function")return le(e,Me(e));if(typeof e=="string")return Y(e);switch(e){case _:return Y("Suspense");case E:return Y("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return Le(e.render);case y:return M(e.type,r,t);case C:{var n=e,i=n._payload,u=n._init;try{return M(u(i),r,t)}catch{}}}return""}var N=Object.prototype.hasOwnProperty,ce={},de=j.ReactDebugCurrentFrame;function U(e){if(e){var r=e._owner,t=M(e.type,e._source,r?r.type:null);de.setExtraStackFrame(t)}else de.setExtraStackFrame(null)}function Ne(e,r,t,n,i){{var u=Function.call.bind(N);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var p=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw p.name="Invariant Violation",p}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(U(i),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),U(null)),a instanceof Error&&!(a.message in ce)&&(ce[a.message]=!0,U(i),v("Failed %s type: %s",t,a.message),U(null))}}}var Ue=Array.isArray;function J(e){return Ue(e)}function Ve(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function qe(e){try{return ve(e),!1}catch{return!0}}function ve(e){return""+e}function pe(e){if(qe(e))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ve(e)),ve(e)}var F=j.ReactCurrentOwner,Be={key:!0,ref:!0,__self:!0,__source:!0},be,ge,z;z={};function Je(e){if(N.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ze(e){if(N.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Ge(e,r){if(typeof e.ref=="string"&&F.current&&r&&F.current.stateNode!==r){var t=h(F.current.type);z[t]||(v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',h(F.current.type),e.ref),z[t]=!0)}}function He(e,r){{var t=function(){be||(be=!0,v("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function Xe(e,r){{var t=function(){ge||(ge=!0,v("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var Ke=function(e,r,t,n,i,u,o){var a={$$typeof:c,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function Ze(e,r,t,n,i){{var u,o={},a=null,p=null;t!==void 0&&(pe(t),a=""+t),ze(r)&&(pe(r.key),a=""+r.key),Je(r)&&(p=r.ref,Ge(r,i));for(u in r)N.call(r,u)&&!Be.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)o[u]===void 0&&(o[u]=s[u])}if(a||p){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&He(o,f),p&&Xe(o,f)}return Ke(e,a,p,i,n,F.current,o)}}var G=j.ReactCurrentOwner,Ee=j.ReactDebugCurrentFrame;function x(e){if(e){var r=e._owner,t=M(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}var H;H=!1;function X(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function Re(){{if(G.current){var e=h(G.current.type);if(e)return` + +Check the render method of \``+e+"`."}return""}}function Qe(e){return""}var _e={};function er(e){{var r=Re();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=` + +Check the top-level render call using <`+t+">.")}return r}}function me(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=er(r);if(_e[t])return;_e[t]=!0;var n="";e&&e._owner&&e._owner!==G.current&&(n=" It was passed a child from "+h(e._owner.type)+"."),x(e),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),x(null)}}function ye(e,r){{if(typeof e!="object")return;if(J(e))for(var t=0;t",a=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,a)}var f=Ze(e,r,t,i,u);if(f==null)return f;if(o){var R=r.children;if(R!==void 0)if(n)if(J(R)){for(var k=0;k{if(d.current)return b();d.current=!0},c)}function vr({baseMaterial:b,vertexShader:c,fragmentShader:d,uniforms:g,cacheKey:O,patchMap:w,attach:P,...m},l){const _=W.useMemo(()=>new ur({baseMaterial:b,vertexShader:c,fragmentShader:d,uniforms:g,cacheKey:O,patchMap:w,...m}),[b]);return dr(()=>{_.update({vertexShader:c,fragmentShader:d,uniforms:g,patchMap:w,cacheKey:O})},[c,d,g,w,O]),W.useEffect(()=>()=>_.dispose(),[_]),cr.jsx("primitive",{ref:l,attach:P??"material",object:_,...m})}const pr=W.forwardRef(vr);module.exports=pr; +//# sourceMappingURL=react.cjs.map diff --git a/entry/cjs/react.cjs.map b/entry/cjs/react.cjs.map new file mode 100644 index 0000000..6589ab3 --- /dev/null +++ b/entry/cjs/react.cjs.map @@ -0,0 +1 @@ +{"version":3,"file":"react.cjs","sources":["../../../node_modules/react/cjs/react-jsx-runtime.production.min.js","../../../node_modules/react/cjs/react-jsx-runtime.development.js","../../../node_modules/react/jsx-runtime.js","../../../src/React/index.tsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n'use strict';\n\nvar React = require('react');\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar assign = Object.assign;\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('')) {\n _frame = _frame.replace('', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nvar ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown;\nvar specialPropRefWarningShown;\nvar didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config, self) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingKey = function () {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n }\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingRef = function () {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * https://github.com/reactjs/rfcs/pull/107\n * @param {*} type\n * @param {object} props\n * @param {string} key\n */\n\nfunction jsxDEV(type, config, maybeKey, source, self) {\n {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null; // Currently, key can be spread in as a prop. This causes a potential\n // issue if key is also explicitly declared (ie.
\n // or
). We want to deprecate key spread,\n // but as an intermediary step, we will use jsxDEV for everything except\n //
, because we aren't currently able to tell if\n // key is explicitly declared to be undefined or not.\n\n if (maybeKey !== undefined) {\n {\n checkKeyStringCoercion(maybeKey);\n }\n\n key = '' + maybeKey;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n if (hasValidRef(config)) {\n ref = config.ref;\n warnIfStringRefCannotBeAutoConverted(config, self);\n } // Remaining properties are added to a new props object\n\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n }\n}\n\nvar ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\n\nfunction isValidElement(object) {\n {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n }\n}\n\nfunction getDeclarationErrorAddendum() {\n {\n if (ReactCurrentOwner$1.current) {\n var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n }\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n }\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n }\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\n\nfunction jsxWithValidation(type, props, key, isStaticChildren, source, self) {\n {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendum(source);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n\n var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n var children = props.children;\n\n if (children !== undefined) {\n if (isStaticChildren) {\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n validateChildKeys(children[i], type);\n }\n\n if (Object.freeze) {\n Object.freeze(children);\n }\n } else {\n error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');\n }\n } else {\n validateChildKeys(children, type);\n }\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n }\n} // These two functions exist to still get child warnings in dev\n// even with the prod transform. This means that jsxDEV is purely\n// opt-in behavior for better messages but that we won't stop\n// giving you warnings if you use production apis.\n\nfunction jsxWithValidationStatic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, true);\n }\n}\nfunction jsxWithValidationDynamic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, false);\n }\n}\n\nvar jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.\n// for now we can ship identical prod functions\n\nvar jsxs = jsxWithValidationStatic ;\n\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsx;\nexports.jsxs = jsxs;\n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","import { AttachType } from \"@react-three/fiber/dist/declarations/src/core/renderer\";\r\nimport * as React from \"react\";\r\nimport { Material } from \"three\";\r\nimport CustomShaderMaterialImpl, { MaterialConstructor } from \"../index\";\r\nimport { CustomShaderMaterialProps } from \"./types\";\r\n\r\nfunction useDidUpdateEffect(\r\n fn: (...opts: any[]) => any,\r\n inputs: React.DependencyList\r\n) {\r\n const didMountRef = React.useRef(false);\r\n\r\n React.useEffect(() => {\r\n if (didMountRef.current) {\r\n return fn();\r\n }\r\n didMountRef.current = true;\r\n }, inputs);\r\n}\r\n\r\nfunction CustomShaderMaterial(\r\n {\r\n baseMaterial,\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n cacheKey,\r\n patchMap,\r\n attach,\r\n ...opts\r\n }: CustomShaderMaterialProps,\r\n ref: React.Ref>\r\n) {\r\n const material = React.useMemo(() => {\r\n return new CustomShaderMaterialImpl({\r\n baseMaterial,\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n cacheKey,\r\n patchMap,\r\n ...opts,\r\n });\r\n }, [baseMaterial]);\r\n\r\n useDidUpdateEffect(() => {\r\n material.update({\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n patchMap,\r\n cacheKey,\r\n });\r\n }, [vertexShader, fragmentShader, uniforms, patchMap, cacheKey]);\r\n\r\n React.useEffect(() => () => material.dispose(), [material]);\r\n\r\n return (\r\n \r\n );\r\n}\r\n\r\n// export default React.forwardRef(CustomShaderMaterial) as <\r\n// T extends MaterialConstructor\r\n// >(\r\n// props: CustomShaderMaterialProps & { ref?: React.Ref> }\r\n// ) => React.ReactElement;\r\n\r\nexport default React.forwardRef(CustomShaderMaterial) as <\r\n T extends MaterialConstructor = typeof Material\r\n>(\r\n props: CustomShaderMaterialProps & {\r\n ref?: React.Ref>;\r\n attach?: AttachType;\r\n }\r\n) => React.ReactElement;\r\n\r\nexport { type CustomShaderMaterialProps } from \"./types\";\r\n"],"names":["f","require$$0","k","l","m","n","p","q","c","a","g","b","d","e","h","reactJsxRuntime_production_min","React","REACT_ELEMENT_TYPE","REACT_PORTAL_TYPE","REACT_FRAGMENT_TYPE","REACT_STRICT_MODE_TYPE","REACT_PROFILER_TYPE","REACT_PROVIDER_TYPE","REACT_CONTEXT_TYPE","REACT_FORWARD_REF_TYPE","REACT_SUSPENSE_TYPE","REACT_SUSPENSE_LIST_TYPE","REACT_MEMO_TYPE","REACT_LAZY_TYPE","REACT_OFFSCREEN_TYPE","MAYBE_ITERATOR_SYMBOL","FAUX_ITERATOR_SYMBOL","getIteratorFn","maybeIterable","maybeIterator","ReactSharedInternals","error","format","_len2","args","_key2","printWarning","level","ReactDebugCurrentFrame","stack","argsWithFormat","item","enableScopeAPI","enableCacheElement","enableTransitionTracing","enableLegacyHidden","enableDebugTracing","REACT_MODULE_REFERENCE","isValidElementType","type","getWrappedName","outerType","innerType","wrapperName","displayName","functionName","getContextName","getComponentNameFromType","context","provider","outerName","lazyComponent","payload","init","assign","disabledDepth","prevLog","prevInfo","prevWarn","prevError","prevGroup","prevGroupCollapsed","prevGroupEnd","disabledLog","disableLogs","props","reenableLogs","ReactCurrentDispatcher","prefix","describeBuiltInComponentFrame","name","source","ownerFn","x","match","reentry","componentFrameCache","PossiblyWeakMap","describeNativeComponentFrame","fn","construct","frame","control","previousPrepareStackTrace","previousDispatcher","Fake","sample","sampleLines","controlLines","_frame","syntheticFrame","describeFunctionComponentFrame","shouldConstruct","Component","prototype","describeUnknownElementTypeFrameInDEV","hasOwnProperty","loggedTypeFailures","setCurrentlyValidatingElement","element","owner","checkPropTypes","typeSpecs","values","location","componentName","has","typeSpecName","error$1","err","ex","isArrayImpl","isArray","typeName","value","hasToStringTag","willCoercionThrow","testStringCoercion","checkKeyStringCoercion","ReactCurrentOwner","RESERVED_PROPS","specialPropKeyWarningShown","specialPropRefWarningShown","didWarnAboutStringRefs","hasValidRef","config","getter","hasValidKey","warnIfStringRefCannotBeAutoConverted","self","defineKeyPropWarningGetter","warnAboutAccessingKey","defineRefPropWarningGetter","warnAboutAccessingRef","ReactElement","key","ref","jsxDEV","maybeKey","propName","defaultProps","ReactCurrentOwner$1","ReactDebugCurrentFrame$1","setCurrentlyValidatingElement$1","propTypesMisspellWarningShown","isValidElement","object","getDeclarationErrorAddendum","getSourceInfoErrorAddendum","ownerHasKeyUseWarning","getCurrentComponentErrorInfo","parentType","info","parentName","validateExplicitKey","currentComponentErrorInfo","childOwner","validateChildKeys","node","i","child","iteratorFn","iterator","step","validatePropTypes","propTypes","_name","validateFragmentProps","fragment","keys","jsxWithValidation","isStaticChildren","validType","sourceInfo","typeString","children","jsxWithValidationStatic","jsxWithValidationDynamic","jsx","jsxs","reactJsxRuntime_development","jsxRuntimeModule","require$$1","useDidUpdateEffect","inputs","didMountRef","CustomShaderMaterial","baseMaterial","vertexShader","fragmentShader","uniforms","cacheKey","patchMap","attach","opts","material","CustomShaderMaterialImpl","index"],"mappings":";;;;;;;;4CASa,IAAIA,EAAEC,EAAiBC,EAAE,OAAO,IAAI,eAAe,EAAEC,EAAE,OAAO,IAAI,gBAAgB,EAAEC,EAAE,OAAO,UAAU,eAAeC,EAAEL,EAAE,mDAAmD,kBAAkBM,EAAE,CAAC,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,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AAY,QACd,OAAO1G,EAAG,EAEZ0G,EAAY,QAAU,IACrBD,CAAM,CACX,CAEA,SAASE,GACP,CACE,aAAAC,EACA,aAAAC,EACA,eAAAC,EACA,SAAAC,EACA,SAAAC,EACA,SAAAC,EACA,OAAAC,EACA,GAAGC,CACL,EACA1D,EACA,CACM,MAAA2D,EAAWlM,EAAM,QAAQ,IACtB,IAAImM,GAAyB,CAClC,aAAAT,EACA,aAAAC,EACA,eAAAC,EACA,SAAAC,EACA,SAAAC,EACA,SAAAC,EACA,GAAGE,CAAA,CACJ,EACA,CAACP,CAAY,CAAC,EAEjB,OAAAJ,GAAmB,IAAM,CACvBY,EAAS,OAAO,CACd,aAAAP,EACA,eAAAC,EACA,SAAAC,EACA,SAAAE,EACA,SAAAD,CAAA,CACD,CAAA,EACA,CAACH,EAAcC,EAAgBC,EAAUE,EAAUD,CAAQ,CAAC,EAEzD9L,EAAA,UAAU,IAAM,IAAMkM,EAAS,UAAW,CAACA,CAAQ,CAAC,EAGxDjB,GAAA,IAAC,YAAA,CACC,IAAA1C,EACA,OAAQyD,GAAU,WAClB,OAAQE,EACP,GAAGD,CAAA,CAAA,CAGV,CAQA,MAAAG,GAAepM,EAAM,WAAWyL,EAAoB","x_google_ignoreList":[0,1,2]} \ No newline at end of file diff --git a/entry/cjs/vanilla.cjs b/entry/cjs/vanilla.cjs new file mode 100644 index 0000000..12cb9a7 --- /dev/null +++ b/entry/cjs/vanilla.cjs @@ -0,0 +1,224 @@ +"use strict";const D=require("three");function x(s){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const d=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(i,t,d.get?d:{enumerable:!0,get:()=>s[t]})}}return i.default=s,Object.freeze(i)}const T=x(D),O=` + +#ifdef IS_VERTEX + vec3 csm_Position; + vec4 csm_PositionRaw; + vec3 csm_Normal; + + // csm_PointSize + #ifdef IS_POINTSMATERIAL + float csm_PointSize; + #endif +#else + vec4 csm_DiffuseColor; + vec4 csm_FragColor; + float csm_FragColorInfluence; + + // csm_Emissive, csm_Roughness, csm_Metalness + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL + vec3 csm_Emissive; + float csm_Roughness; + float csm_Metalness; + float csm_Iridescence; + + #if defined IS_MESHPHYSICALMATERIAL + float csm_Clearcoat; + float csm_ClearcoatRoughness; + vec3 csm_ClearcoatNormal; + float csm_Transmission; + float csm_Thickness; + #endif + #endif + + // csm_AO + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL + float csm_AO; + #endif + + // csm_Bump + #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL + vec3 csm_Bump; + #endif + + float csm_DepthAlpha; +#endif +`,b=` + +#ifdef IS_VERTEX + // csm_Position & csm_PositionRaw + #ifdef IS_UNKNOWN + csm_Position = vec3(0.0); + csm_PositionRaw = vec4(0.0); + csm_Normal = vec3(0.0); + #else + csm_Position = position; + csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.); + csm_Normal = normal; + #endif + + // csm_PointSize + #ifdef IS_POINTSMATERIAL + csm_PointSize = size; + #endif +#else + csm_FragColorInfluence = 0.0; + + // csm_DiffuseColor & csm_FragColor + #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHDISTANCEMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL + csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0); + csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0); + #else + #ifdef USE_MAP + vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv); + + #ifdef DECODE_VIDEO_TEXTURE + // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved) + _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w); + #endif + + csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor; + csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor; + #else + csm_DiffuseColor = vec4(diffuse, opacity); + csm_FragColor = vec4(diffuse, opacity); + #endif + #endif + + // csm_Emissive, csm_Roughness, csm_Metalness + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL + csm_Emissive = emissive; + csm_Roughness = roughness; + csm_Metalness = metalness; + + #ifdef USE_IRIDESCENCE + csm_Iridescence = iridescence; + #else + csm_Iridescence = 0.0; + #endif + + #if defined IS_MESHPHYSICALMATERIAL + #ifdef USE_CLEARCOAT + csm_Clearcoat = clearcoat; + csm_ClearcoatRoughness = clearcoatRoughness; + #else + csm_Clearcoat = 0.0; + csm_ClearcoatRoughness = 0.0; + #endif + + #ifdef USE_TRANSMISSION + csm_Transmission = transmission; + csm_Thickness = thickness; + #else + csm_Transmission = 0.0; + csm_Thickness = 0.0; + #endif + #endif + #endif + + // csm_AO + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL + csm_AO = 0.0; + #endif + + // csm_Bump + #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL + csm_Bump = vec3(0.0); + #endif + + csm_DepthAlpha = 1.0; +#endif +`,y=` + varying mat4 csm_internal_vModelViewMatrix; +`,w=` + csm_internal_vModelViewMatrix = modelViewMatrix; +`,k=` + varying mat4 csm_internal_vModelViewMatrix; +`,j=` + +`,e={diffuse:"csm_DiffuseColor",normal:"csm_Normal",roughness:"csm_Roughness",metalness:"csm_Metalness",emissive:"csm_Emissive",ao:"csm_AO",bump:"csm_Bump",clearcoat:"csm_Clearcoat",clearcoatRoughness:"csm_ClearcoatRoughness",clearcoatNormal:"csm_ClearcoatNormal",transmission:"csm_Transmission",thickness:"csm_Thickness",iridescence:"csm_Iridescence",pointSize:"csm_PointSize",fragColor:"csm_FragColor",depthAlpha:"csm_DepthAlpha",fragColorInfluence:"csm_FragColorInfluence",position:"csm_Position",positionRaw:"csm_PositionRaw"},F={[`${e.position}`]:"*",[`${e.positionRaw}`]:"*",[`${e.normal}`]:"*",[`${e.depthAlpha}`]:"*",[`${e.pointSize}`]:["PointsMaterial"],[`${e.diffuse}`]:"*",[`${e.fragColor}`]:"*",[`${e.fragColorInfluence}`]:["*"],[`${e.emissive}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${e.roughness}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${e.metalness}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${e.iridescence}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${e.ao}`]:["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"],[`${e.bump}`]:["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"],[`${e.clearcoat}`]:["MeshPhysicalMaterial"],[`${e.clearcoatRoughness}`]:["MeshPhysicalMaterial"],[`${e.clearcoatNormal}`]:["MeshPhysicalMaterial"],[`${e.transmission}`]:["MeshPhysicalMaterial"],[`${e.thickness}`]:["MeshPhysicalMaterial"]},B={"*":{"#include ":T.ShaderChunk.lights_physical_fragment,"#include ":T.ShaderChunk.transmission_fragment},[`${e.normal}`]:{"#include ":` + vec3 objectNormal = ${e.normal}; + #ifdef USE_TANGENT + vec3 objectTangent = vec3( tangent.xyz ); + #endif + `},[`${e.position}`]:{"#include ":` + vec3 transformed = ${e.position}; + `},[`${e.positionRaw}`]:{"#include ":` + vec4 csm_internal_positionUnprojected = ${e.positionRaw}; + mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix; + #ifdef USE_INSTANCING + csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix; + #endif + csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected; + vec3 transformed = csm_internal_positionUnprojected.xyz; + `},[`${e.pointSize}`]:{"gl_PointSize = size;":` + gl_PointSize = ${e.pointSize}; + `},[`${e.diffuse}`]:{"#include ":` + #include + diffuseColor = ${e.diffuse}; + `},[`${e.fragColor}`]:{"#include ":` + #include + gl_FragColor = mix(gl_FragColor, ${e.fragColor}, ${e.fragColorInfluence}); + `},[`${e.emissive}`]:{"vec3 totalEmissiveRadiance = emissive;":` + vec3 totalEmissiveRadiance = ${e.emissive}; + `},[`${e.roughness}`]:{"#include ":` + #include + roughnessFactor = ${e.roughness}; + `},[`${e.metalness}`]:{"#include ":` + #include + metalnessFactor = ${e.metalness}; + `},[`${e.ao}`]:{"#include ":` + #include + reflectedLight.indirectDiffuse *= 1. - ${e.ao}; + `},[`${e.bump}`]:{"#include ":` + #include + + vec3 csm_internal_orthogonal = ${e.bump} - (dot(${e.bump}, normal) * normal); + vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal; + normal = normalize(normal - csm_internal_projectedbump); + `},[`${e.depthAlpha}`]:{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":` + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * ${e.depthAlpha} ); + `,"gl_FragColor = packDepthToRGBA( fragCoordZ );":` + if(${e.depthAlpha} > 0.0) discard; + gl_FragColor = packDepthToRGBA( dist ); + `,"gl_FragColor = packDepthToRGBA( dist );":` + if(${e.depthAlpha} > 0.0) discard; + gl_FragColor = packDepthToRGBA( dist ); + `},[`${e.clearcoat}`]:{"material.clearcoat = clearcoat;":`material.clearcoat = ${e.clearcoat};`},[`${e.clearcoatRoughness}`]:{"material.clearcoatRoughness = clearcoatRoughness;":`material.clearcoatRoughness = ${e.clearcoatRoughness};`},[`${e.clearcoatNormal}`]:{"#include ":` + vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal); + vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal; + vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump); + `},[`${e.transmission}`]:{"material.transmission = transmission;":` + material.transmission = ${e.transmission}; + `},[`${e.thickness}`]:{"material.thickness = thickness;":` + material.thickness = ${e.thickness}; + `},[`${e.iridescence}`]:{"material.iridescence = iridescence;":` + material.iridescence = ${e.iridescence}; + `}},z={clearcoat:[e.clearcoat,e.clearcoatNormal,e.clearcoatRoughness],transmission:[e.transmission],iridescence:[e.iridescence]};function U(s){let i=0;for(let f=0;f>>0;return String(t)}function V(s){try{new s}catch(i){if(i.message.indexOf("is not a constructor")>=0)return!1}return!0}function H(s,i){for(const t in i)i[t]instanceof Object&&Object.assign(i[t],H(s[t],i[t]));return Object.assign(s||{},i),s}function P(s){return s.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")}function G(s){return s.replace(/\n/g,"")}function Y(s){return s.replace(/\s/g,"")}function W(s){const i=s.name;return Y(G(s.toString()))===`${i}(){}`}class q extends T.Material{constructor({baseMaterial:i,vertexShader:t,fragmentShader:d,uniforms:f,patchMap:R,cacheKey:M,...m}){if(!i)throw new Error("CustomShaderMaterial: baseMaterial is required.");let n;if(V(i)){const l=Object.keys(m).length===0;n=new i(l?void 0:m)}else n=i,Object.assign(n,m);if(["ShaderMaterial","RawShaderMaterial"].includes(n.type))throw new Error(`CustomShaderMaterial does not support ${n.type} as a base material.`);super(),this.uniforms={},this.vertexShader="",this.fragmentShader="";const o=n;o.name=`CustomShaderMaterial<${n.name}>`,o.update=this.update.bind(o),o.__csm={prevOnBeforeCompile:n.onBeforeCompile};const a={...o.uniforms||{},...f||{}};return o.uniforms=this.uniforms=a,o.vertexShader=this.vertexShader=t||"",o.fragmentShader=this.fragmentShader=d||"",o.update({fragmentShader:o.fragmentShader,vertexShader:o.vertexShader,uniforms:o.uniforms,patchMap:R,cacheKey:M}),o}update({fragmentShader:i,vertexShader:t,uniforms:d,cacheKey:f,patchMap:R}){const M=P(t||""),m=P(i||""),n=this;d&&(n.uniforms=d),t&&(n.vertexShader=t),i&&(n.fragmentShader=i),Object.entries(z).forEach(([a,l])=>{for(const h in l){const c=l[h];(m&&m.includes(c)||M&&M.includes(c))&&(n[a]||(n[a]=1))}});const S=n.__csm.prevOnBeforeCompile,o=!W(S),C=(a,l,h)=>{var p;let c,_="";if(l){const r=/void\s+main\s*\(\s*\)[^{]*{((?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{[^{}]*})*})*})*})*})/gm;c=(p=l.matchAll(r).next().value)==null?void 0:p[1],c&&(c=c.slice(0,-1));const v=l.indexOf("void main() {");_=l.slice(0,v)}if(o){a=a.replace("void main() {",` + // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial + + ${_} + + void main() { + `);const r=a.lastIndexOf("//~CSM_MAIN_END");if(r!==-1){const I=` + ${c?`${c}`:""} + //~CSM_MAIN_END + `;a=a.slice(0,r)+I+a.slice(r)}}else{const r=/void\s*main\s*\(\s*\)\s*{/gm;a=a.replace(r,` + // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial + + ${h?k:y} + ${O} + + ${_} + + void main() { + ${b} + ${h?j:w} + + ${c?`${c}`:""} + //~CSM_MAIN_END + `)}return a};n.onBeforeCompile=(a,l)=>{S==null||S(a,l);const c=H(B,R||{}),_=n.type,p=_?`#define IS_${_.toUpperCase()}; +`:`#define IS_UNKNOWN; +`;a.vertexShader=p+`#define IS_VERTEX +`+a.vertexShader,a.fragmentShader=p+`#define IS_FRAGMENT +`+a.fragmentShader;for(const r in c){const I=r==="*"||M&&M.includes(r);if(r==="*"||m&&m.includes(r)||I){const A=F[r];if(A&&A!=="*"&&(Array.isArray(A)?!A.includes(_):A!==_)){console.error(`CustomShaderMaterial: ${r} is not available in ${_}. Shader cannot compile.`);return}const $=c[r];for(const g in $){const u=$[g];if(typeof u=="object"){const N=u.type,L=u.value;N==="fs"?a.fragmentShader=a.fragmentShader.replace(g,L):N==="vs"&&(a.vertexShader=a.vertexShader.replace(g,L))}else u&&(a.vertexShader=a.vertexShader.replace(g,u),a.fragmentShader=a.fragmentShader.replace(g,u))}}}a.vertexShader=C(a.vertexShader,M,!1),a.fragmentShader=C(a.fragmentShader,m,!0),d&&(a.uniforms={...a.uniforms,...n.uniforms}),n.uniforms=a.uniforms};const E=n.customProgramCacheKey;n.customProgramCacheKey=()=>((f==null?void 0:f())||U((M||"")+(m||"")))+(E==null?void 0:E.call(n)),n.needsUpdate=!0}}module.exports=q; +//# sourceMappingURL=vanilla.cjs.map diff --git a/entry/cjs/vanilla.cjs.map b/entry/cjs/vanilla.cjs.map new file mode 100644 index 0000000..71f376b --- /dev/null +++ b/entry/cjs/vanilla.cjs.map @@ -0,0 +1 @@ +{"version":3,"file":"vanilla.cjs","sources":["../../../src/defaults.ts","../../../src/maps/keywordMap.ts","../../../src/maps/availabilityMap.ts","../../../src/maps/patchMap.ts","../../../src/maps/requiredPropsMap.ts","../../../src/sdbm.js","../../../src/utils.ts","../../../src/index.ts"],"sourcesContent":["export const defaultCsmDefinitions = /* glsl */ `\r\n \r\n#ifdef IS_VERTEX\r\n vec3 csm_Position;\r\n vec4 csm_PositionRaw;\r\n vec3 csm_Normal;\r\n\r\n // csm_PointSize\r\n #ifdef IS_POINTSMATERIAL\r\n float csm_PointSize;\r\n #endif\r\n#else\r\n vec4 csm_DiffuseColor;\r\n vec4 csm_FragColor;\r\n float csm_FragColorInfluence;\r\n\r\n // csm_Emissive, csm_Roughness, csm_Metalness\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\r\n vec3 csm_Emissive;\r\n float csm_Roughness;\r\n float csm_Metalness;\r\n float csm_Iridescence;\r\n \r\n #if defined IS_MESHPHYSICALMATERIAL\r\n float csm_Clearcoat;\r\n float csm_ClearcoatRoughness;\r\n vec3 csm_ClearcoatNormal;\r\n float csm_Transmission;\r\n float csm_Thickness;\r\n #endif\r\n #endif\r\n\r\n // csm_AO\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\r\n float csm_AO;\r\n #endif\r\n\r\n // csm_Bump\r\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \r\n vec3 csm_Bump;\r\n #endif\r\n\r\n float csm_DepthAlpha;\r\n#endif\r\n`;\r\n\r\nexport const defaultCsmMainDefinitions = /* glsl */ `\r\n\r\n#ifdef IS_VERTEX\r\n // csm_Position & csm_PositionRaw\r\n #ifdef IS_UNKNOWN\r\n csm_Position = vec3(0.0);\r\n csm_PositionRaw = vec4(0.0);\r\n csm_Normal = vec3(0.0);\r\n #else\r\n csm_Position = position;\r\n csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.);\r\n csm_Normal = normal;\r\n #endif\r\n\r\n // csm_PointSize\r\n #ifdef IS_POINTSMATERIAL\r\n csm_PointSize = size;\r\n #endif\r\n#else\r\n csm_FragColorInfluence = 0.0;\r\n\r\n // csm_DiffuseColor & csm_FragColor\r\n #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHDISTANCEMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL\r\n csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0);\r\n csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\r\n #else\r\n #ifdef USE_MAP\r\n vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv);\r\n\r\n #ifdef DECODE_VIDEO_TEXTURE\r\n // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)\r\n _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w);\r\n #endif\r\n\r\n csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\r\n csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\r\n #else\r\n csm_DiffuseColor = vec4(diffuse, opacity);\r\n csm_FragColor = vec4(diffuse, opacity);\r\n #endif\r\n #endif\r\n\r\n // csm_Emissive, csm_Roughness, csm_Metalness\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\r\n csm_Emissive = emissive;\r\n csm_Roughness = roughness;\r\n csm_Metalness = metalness;\r\n\r\n #ifdef USE_IRIDESCENCE\r\n csm_Iridescence = iridescence;\r\n #else\r\n csm_Iridescence = 0.0;\r\n #endif\r\n\r\n #if defined IS_MESHPHYSICALMATERIAL\r\n #ifdef USE_CLEARCOAT\r\n csm_Clearcoat = clearcoat;\r\n csm_ClearcoatRoughness = clearcoatRoughness;\r\n #else\r\n csm_Clearcoat = 0.0;\r\n csm_ClearcoatRoughness = 0.0;\r\n #endif\r\n\r\n #ifdef USE_TRANSMISSION\r\n csm_Transmission = transmission;\r\n csm_Thickness = thickness;\r\n #else\r\n csm_Transmission = 0.0;\r\n csm_Thickness = 0.0;\r\n #endif\r\n #endif\r\n #endif\r\n\r\n // csm_AO\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\r\n csm_AO = 0.0;\r\n #endif\r\n\r\n // csm_Bump\r\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \r\n csm_Bump = vec3(0.0);\r\n #endif\r\n\r\n csm_DepthAlpha = 1.0;\r\n#endif\r\n`;\r\n\r\nexport const defaultVertDefinitions = /* glsl */ `\r\n varying mat4 csm_internal_vModelViewMatrix;\r\n`;\r\n\r\nexport const defaultVertMain = /* glsl */ `\r\n csm_internal_vModelViewMatrix = modelViewMatrix;\r\n`;\r\n\r\nexport const defaultFragDefinitions = /* glsl */ `\r\n varying mat4 csm_internal_vModelViewMatrix;\r\n`;\r\n\r\nexport const defaultFragMain = /* glsl */ `\r\n \r\n`;\r\n","export const keywordMap = {\r\n // PBR\r\n diffuse: \"csm_DiffuseColor\", // Color + alpha\r\n normal: \"csm_Normal\", // Normal\r\n roughness: \"csm_Roughness\", // Roughness\r\n metalness: \"csm_Metalness\", // Metalness\r\n emissive: \"csm_Emissive\", // Emissive\r\n ao: \"csm_AO\", // AO\r\n bump: \"csm_Bump\", // Bump\r\n clearcoat: \"csm_Clearcoat\", // Clearcoat factor\r\n clearcoatRoughness: \"csm_ClearcoatRoughness\", // Clearcoat roughness\r\n clearcoatNormal: \"csm_ClearcoatNormal\", // Clearcoat normals\r\n transmission: \"csm_Transmission\", // Transmission\r\n thickness: \"csm_Thickness\", // Thickness\r\n iridescence: \"csm_Iridescence\", // Iridescence\r\n\r\n // Extras\r\n pointSize: \"csm_PointSize\",\r\n fragColor: \"csm_FragColor\",\r\n depthAlpha: \"csm_DepthAlpha\", // Depth\r\n fragColorInfluence: \"csm_FragColorInfluence\", // Unlit factor\r\n\r\n // Vert\r\n position: \"csm_Position\",\r\n positionRaw: \"csm_PositionRaw\",\r\n};\r\n","import { keywordMap } from \"./keywordMap\";\r\n\r\n// Map of CSM keywords to the materials they are available in\r\n// Some keywords are only available in certain materials\r\nexport const availabilityMap = {\r\n [`${keywordMap.position}`]: \"*\",\r\n [`${keywordMap.positionRaw}`]: \"*\",\r\n [`${keywordMap.normal}`]: \"*\",\r\n [`${keywordMap.depthAlpha}`]: \"*\",\r\n [`${keywordMap.pointSize}`]: [\"PointsMaterial\"],\r\n\r\n [`${keywordMap.diffuse}`]: \"*\",\r\n [`${keywordMap.fragColor}`]: \"*\",\r\n [`${keywordMap.fragColorInfluence}`]: [\"*\"],\r\n [`${keywordMap.emissive}`]: [\"MeshStandardMaterial\", \"MeshPhysicalMaterial\"],\r\n [`${keywordMap.roughness}`]: [\"MeshStandardMaterial\", \"MeshPhysicalMaterial\"],\r\n [`${keywordMap.metalness}`]: [\"MeshStandardMaterial\", \"MeshPhysicalMaterial\"],\r\n [`${keywordMap.iridescence}`]: [\r\n \"MeshStandardMaterial\",\r\n \"MeshPhysicalMaterial\",\r\n ],\r\n [`${keywordMap.ao}`]: [\r\n \"MeshStandardMaterial\",\r\n \"MeshPhysicalMaterial\",\r\n \"MeshBasicMaterial\",\r\n \"MeshLambertMaterial\",\r\n \"MeshPhongMaterial\",\r\n \"MeshToonMaterial\",\r\n ],\r\n [`${keywordMap.bump}`]: [\r\n \"MeshLambertMaterial\",\r\n \"MeshMatcapMaterial\",\r\n \"MeshNormalMaterial\",\r\n \"MeshPhongMaterial\",\r\n \"MeshPhysicalMaterial\",\r\n \"MeshStandardMaterial\",\r\n \"MeshToonMaterial\",\r\n \"ShadowMaterial\",\r\n ],\r\n [`${keywordMap.clearcoat}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.clearcoatRoughness}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.clearcoatNormal}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.transmission}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.thickness}`]: [\"MeshPhysicalMaterial\"],\r\n};\r\n","import * as THREE from \"three\";\r\nimport { CSMPatchMap } from \"../types\";\r\nimport { keywordMap } from \"./keywordMap\";\r\n\r\n// Map of CSM keywords to their substitutions\r\nexport const defaultPatchMap: CSMPatchMap = {\r\n // VERT\r\n \"*\": {\r\n \"#include \":\r\n THREE.ShaderChunk.lights_physical_fragment,\r\n \"#include \": THREE.ShaderChunk.transmission_fragment,\r\n },\r\n [`${keywordMap.normal}`]: {\r\n \"#include \": `\r\n vec3 objectNormal = ${keywordMap.normal};\r\n #ifdef USE_TANGENT\r\n\t vec3 objectTangent = vec3( tangent.xyz );\r\n #endif\r\n `,\r\n },\r\n [`${keywordMap.position}`]: {\r\n \"#include \": `\r\n vec3 transformed = ${keywordMap.position};\r\n `,\r\n },\r\n [`${keywordMap.positionRaw}`]: {\r\n \"#include \": `\r\n vec4 csm_internal_positionUnprojected = ${keywordMap.positionRaw};\r\n mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix;\r\n #ifdef USE_INSTANCING\r\n csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix;\r\n #endif\r\n csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected;\r\n vec3 transformed = csm_internal_positionUnprojected.xyz;\r\n `,\r\n },\r\n [`${keywordMap.pointSize}`]: {\r\n \"gl_PointSize = size;\": `\r\n gl_PointSize = ${keywordMap.pointSize};\r\n `,\r\n },\r\n\r\n // FRAG\r\n\r\n [`${keywordMap.diffuse}`]: {\r\n \"#include \": `\r\n #include \r\n diffuseColor = ${keywordMap.diffuse};\r\n `,\r\n },\r\n [`${keywordMap.fragColor}`]: {\r\n \"#include \": `\r\n #include \r\n gl_FragColor = mix(gl_FragColor, ${keywordMap.fragColor}, ${keywordMap.fragColorInfluence});\r\n `,\r\n },\r\n [`${keywordMap.emissive}`]: {\r\n \"vec3 totalEmissiveRadiance = emissive;\": `\r\n vec3 totalEmissiveRadiance = ${keywordMap.emissive};\r\n `,\r\n },\r\n [`${keywordMap.roughness}`]: {\r\n \"#include \": `\r\n #include \r\n roughnessFactor = ${keywordMap.roughness};\r\n `,\r\n },\r\n [`${keywordMap.metalness}`]: {\r\n \"#include \": `\r\n #include \r\n metalnessFactor = ${keywordMap.metalness};\r\n `,\r\n },\r\n [`${keywordMap.ao}`]: {\r\n \"#include \": `\r\n #include \r\n reflectedLight.indirectDiffuse *= 1. - ${keywordMap.ao};\r\n `,\r\n },\r\n [`${keywordMap.bump}`]: {\r\n \"#include \": `\r\n #include \r\n\r\n vec3 csm_internal_orthogonal = ${keywordMap.bump} - (dot(${keywordMap.bump}, normal) * normal);\r\n vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal;\r\n normal = normalize(normal - csm_internal_projectedbump);\r\n `,\r\n },\r\n [`${keywordMap.depthAlpha}`]: {\r\n \"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\": `\r\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * ${keywordMap.depthAlpha} );\r\n `,\r\n \"gl_FragColor = packDepthToRGBA( fragCoordZ );\": `\r\n if(${keywordMap.depthAlpha} > 0.0) discard;\r\n gl_FragColor = packDepthToRGBA( dist );\r\n `,\r\n \"gl_FragColor = packDepthToRGBA( dist );\": `\r\n if(${keywordMap.depthAlpha} > 0.0) discard;\r\n gl_FragColor = packDepthToRGBA( dist );\r\n `,\r\n },\r\n [`${keywordMap.clearcoat}`]: {\r\n \"material.clearcoat = clearcoat;\": `material.clearcoat = ${keywordMap.clearcoat};`,\r\n },\r\n [`${keywordMap.clearcoatRoughness}`]: {\r\n \"material.clearcoatRoughness = clearcoatRoughness;\": `material.clearcoatRoughness = ${keywordMap.clearcoatRoughness};`,\r\n },\r\n [`${keywordMap.clearcoatNormal}`]: {\r\n \"#include \": `\r\n vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal);\r\n vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal;\r\n vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump);\r\n `,\r\n },\r\n [`${keywordMap.transmission}`]: {\r\n \"material.transmission = transmission;\": `\r\n material.transmission = ${keywordMap.transmission};\r\n `,\r\n },\r\n [`${keywordMap.thickness}`]: {\r\n \"material.thickness = thickness;\": `\r\n material.thickness = ${keywordMap.thickness};\r\n `,\r\n },\r\n [`${keywordMap.iridescence}`]: {\r\n \"material.iridescence = iridescence;\": `\r\n material.iridescence = ${keywordMap.iridescence};\r\n `,\r\n },\r\n};\r\n","import { keywordMap } from \"./keywordMap\";\r\n\r\n/**\r\n * Map of props to their keywords\r\n * this is because Three only injects some defines if certain properties are set in the material options.\r\n *\r\n * For example, \"clearcoat\" must be set for 3js to include the #USE_CLEARCOAT define in the shader.\r\n * and thus for our custom clearcoar variant to work\r\n */\r\nexport const requiredPropsMap = {\r\n clearcoat: [\r\n keywordMap.clearcoat,\r\n keywordMap.clearcoatNormal,\r\n keywordMap.clearcoatRoughness,\r\n ],\r\n transmission: [keywordMap.transmission],\r\n iridescence: [keywordMap.iridescence],\r\n};\r\n","//https://github.com/sindresorhus/sdbm\r\n\r\nexport default function sdbm(string) {\r\n let hash = 0;\r\n\r\n for (let i = 0; i < string.length; i++) {\r\n hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;\r\n }\r\n\r\n // Convert it to an unsigned 32-bit integer.\r\n const h = hash >>> 0;\r\n const str = String(h);\r\n return str;\r\n}\r\n","import { MaterialConstructor } from \"./types\";\r\n\r\n// Hacky, yikes!\r\nexport function isConstructor(\r\n f: T | InstanceType\r\n): f is T {\r\n try {\r\n // @ts-ignore\r\n new f();\r\n } catch (err) {\r\n if ((err as any).message.indexOf(\"is not a constructor\") >= 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\n\r\nexport function deepMergeObjects>(\r\n target: T,\r\n source: T\r\n): T {\r\n for (const key in source) {\r\n // @ts-ignore\r\n if (source[key] instanceof Object)\r\n Object.assign(source[key], deepMergeObjects(target[key], source[key]));\r\n }\r\n\r\n Object.assign(target || {}, source);\r\n return target;\r\n}\r\n\r\n// Remove all comments in a string\r\n// both block and inline comments\r\nexport function stripComments(str: string) {\r\n return str.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, \"\");\r\n}\r\n\r\nexport function stripNewLines(str: string) {\r\n return str.replace(/\\n/g, \"\");\r\n}\r\n\r\nexport function stripSpaces(str: string) {\r\n return str.replace(/\\s/g, \"\");\r\n}\r\n\r\nexport function isEmptyFunction(func: Function) {\r\n const funcName = func.name;\r\n return stripSpaces(stripNewLines(func.toString())) === `${funcName}(){}`;\r\n}\r\n","import * as THREE from \"three\";\r\nimport {\r\n defaultCsmDefinitions,\r\n defaultCsmMainDefinitions,\r\n defaultFragDefinitions,\r\n defaultFragMain,\r\n defaultVertDefinitions,\r\n defaultVertMain,\r\n} from \"./defaults\";\r\nimport { availabilityMap, defaultPatchMap } from \"./maps\";\r\nimport { requiredPropsMap } from \"./maps/requiredPropsMap\";\r\nimport hash from \"./sdbm\";\r\nimport * as TYPES from \"./types\";\r\nimport {\r\n deepMergeObjects,\r\n isConstructor,\r\n isEmptyFunction,\r\n stripComments,\r\n} from \"./utils\";\r\n\r\nexport default class CustomShaderMaterial<\r\n T extends TYPES.MaterialConstructor = typeof THREE.Material\r\n> extends THREE.Material {\r\n uniforms: TYPES.Uniform = {};\r\n vertexShader: string = \"\";\r\n fragmentShader: string = \"\";\r\n\r\n constructor({\r\n baseMaterial,\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n patchMap,\r\n cacheKey,\r\n ...opts\r\n }: TYPES.CustomShaderMaterialParameters) {\r\n if (!baseMaterial) {\r\n throw new Error(\"CustomShaderMaterial: baseMaterial is required.\");\r\n }\r\n\r\n let base: THREE.Material;\r\n if (isConstructor(baseMaterial)) {\r\n // If base material is a constructor, instantiate it\r\n // if opts is empty, replace it with undefined\r\n const isEmptyOpts = Object.keys(opts).length === 0;\r\n base = new baseMaterial(isEmptyOpts ? undefined : opts);\r\n } else {\r\n // Else, use the already created instance as the base material\r\n // and copy options onto it\r\n base = baseMaterial;\r\n Object.assign(base, opts);\r\n }\r\n\r\n // Blacklist some materials that are not supported\r\n const blackList = [\"ShaderMaterial\", \"RawShaderMaterial\"];\r\n if (blackList.includes(base.type)) {\r\n throw new Error(\r\n `CustomShaderMaterial does not support ${base.type} as a base material.`\r\n );\r\n }\r\n\r\n super();\r\n\r\n // Return a proxy to the base material with CSM types and methods\r\n const extendedBase = base as typeof base & TYPES.CSMProxy;\r\n extendedBase.name = `CustomShaderMaterial<${base.name}>`;\r\n extendedBase.update = this.update.bind(extendedBase);\r\n extendedBase.__csm = { prevOnBeforeCompile: base.onBeforeCompile };\r\n\r\n const prevUniforms = extendedBase.uniforms || {};\r\n const newUniforms = uniforms || {};\r\n const mergedUniforms = { ...prevUniforms, ...newUniforms };\r\n\r\n extendedBase.uniforms = this.uniforms = mergedUniforms;\r\n extendedBase.vertexShader = this.vertexShader = vertexShader || \"\";\r\n extendedBase.fragmentShader = this.fragmentShader = fragmentShader || \"\";\r\n\r\n // Initialize custom shaders\r\n extendedBase.update({\r\n fragmentShader: extendedBase.fragmentShader,\r\n vertexShader: extendedBase.vertexShader,\r\n uniforms: extendedBase.uniforms,\r\n patchMap,\r\n cacheKey,\r\n });\r\n\r\n return extendedBase;\r\n }\r\n\r\n update({\r\n fragmentShader: _fs,\r\n vertexShader: _vs,\r\n uniforms,\r\n cacheKey,\r\n patchMap,\r\n }: Omit, \"baseMaterial\">) {\r\n // Strip comments from shaders, makes it so that commented keywords are not detected\r\n const vertexShader = stripComments(_vs || \"\");\r\n const fragmentShader = stripComments(_fs || \"\");\r\n\r\n // Get typed `this` for the proxy\r\n const self = this as typeof this & TYPES.CSMProxy;\r\n\r\n // Replace the shaders if they are provided\r\n if (uniforms) self.uniforms = uniforms;\r\n if (_vs) self.vertexShader = _vs;\r\n if (_fs) self.fragmentShader = _fs;\r\n\r\n // Some keywords require certain properties to be set for their chunks to be included via #ifdef\r\n // so we must check if the shaders contain these keywords and set the properties accordingly\r\n Object.entries(requiredPropsMap).forEach(([prop, matchKeywords]) => {\r\n for (const keyword in matchKeywords) {\r\n const matchKeyword = matchKeywords[keyword];\r\n if (\r\n (fragmentShader && fragmentShader.includes(matchKeyword)) ||\r\n (vertexShader && vertexShader.includes(matchKeyword))\r\n ) {\r\n // @ts-ignore\r\n if (!self[prop]) {\r\n // @ts-ignore\r\n self[prop] = 1;\r\n }\r\n }\r\n }\r\n });\r\n\r\n // Check it the previous onBeforeCompile exists\r\n const prevOnBeforeCompile = self.__csm.prevOnBeforeCompile;\r\n const doesHavePreviousBeforeCompile = !isEmptyFunction(prevOnBeforeCompile);\r\n\r\n // Helper function to extend the shader\r\n const extendShader = (\r\n prevShader: string,\r\n newShader?: string,\r\n isFrag?: boolean\r\n ) => {\r\n let mainBody: string | undefined;\r\n let beforeMain: string = \"\";\r\n\r\n // Prepare the main body and beforeMain\r\n if (newShader) {\r\n const mainBodyRegex =\r\n /void\\s+main\\s*\\(\\s*\\)[^{]*{((?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{[^{}]*})*})*})*})*})/gm;\r\n const mainBodyMatches = newShader.matchAll(mainBodyRegex);\r\n mainBody = mainBodyMatches.next().value?.[1];\r\n if (mainBody) mainBody = mainBody.slice(0, -1);\r\n\r\n const mainIndex = newShader.indexOf(\"void main() {\");\r\n beforeMain = newShader.slice(0, mainIndex);\r\n }\r\n\r\n // Inject\r\n if (doesHavePreviousBeforeCompile) {\r\n prevShader = prevShader.replace(\r\n \"void main() {\",\r\n `\r\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\r\n \r\n ${beforeMain}\r\n \r\n void main() {\r\n `\r\n );\r\n\r\n const lastMainEndIndex = prevShader.lastIndexOf(\"//~CSM_MAIN_END\");\r\n\r\n if (lastMainEndIndex !== -1) {\r\n const toAppend = `\r\n ${mainBody ? `${mainBody}` : \"\"}\r\n //~CSM_MAIN_END\r\n `;\r\n prevShader =\r\n prevShader.slice(0, lastMainEndIndex) +\r\n toAppend +\r\n prevShader.slice(lastMainEndIndex);\r\n }\r\n } else {\r\n const regex = /void\\s*main\\s*\\(\\s*\\)\\s*{/gm;\r\n\r\n prevShader = prevShader.replace(\r\n regex,\r\n `\r\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\r\n \r\n ${isFrag ? defaultFragDefinitions : defaultVertDefinitions}\r\n ${defaultCsmDefinitions}\r\n \r\n ${beforeMain}\r\n \r\n void main() {\r\n ${defaultCsmMainDefinitions}\r\n ${isFrag ? defaultFragMain : defaultVertMain}\r\n\r\n ${mainBody ? `${mainBody}` : \"\"}\r\n //~CSM_MAIN_END\r\n `\r\n );\r\n }\r\n\r\n return prevShader;\r\n };\r\n\r\n // Override onBeforeCompile\r\n self.onBeforeCompile = (\r\n shader: THREE.WebGLProgramParametersWithUniforms,\r\n renderer: THREE.WebGLRenderer\r\n ) => {\r\n // Apply previous onBeforeCompile\r\n prevOnBeforeCompile?.(shader, renderer);\r\n\r\n const userPatchMap = patchMap || {};\r\n const mergedPatchMap = deepMergeObjects(defaultPatchMap, userPatchMap);\r\n\r\n // Append some defines\r\n const type = self.type;\r\n const typeDefine = type\r\n ? `#define IS_${type.toUpperCase()};\\n`\r\n : `#define IS_UNKNOWN;\\n`;\r\n shader.vertexShader =\r\n typeDefine + \"#define IS_VERTEX\\n\" + shader.vertexShader;\r\n shader.fragmentShader =\r\n typeDefine + \"#define IS_FRAGMENT\\n\" + shader.fragmentShader;\r\n\r\n // Check if the keyword is available in the current material type\r\n for (const keyword in mergedPatchMap) {\r\n const doesIncludeInVert =\r\n keyword === \"*\" || (vertexShader && vertexShader.includes(keyword));\r\n const doesIncludeInFrag =\r\n keyword === \"*\" ||\r\n (fragmentShader && fragmentShader.includes(keyword));\r\n\r\n if (doesIncludeInFrag || doesIncludeInVert) {\r\n const availableIn = availabilityMap[keyword];\r\n\r\n if (\r\n availableIn &&\r\n availableIn !== \"*\" &&\r\n (Array.isArray(availableIn)\r\n ? !availableIn.includes(type)\r\n : availableIn !== type)\r\n ) {\r\n console.error(\r\n `CustomShaderMaterial: ${keyword} is not available in ${type}. Shader cannot compile.`\r\n );\r\n return;\r\n }\r\n\r\n const patchMap = mergedPatchMap[keyword];\r\n\r\n for (const toReplace in patchMap) {\r\n const replaceWith = patchMap[toReplace];\r\n if (typeof replaceWith === \"object\") {\r\n const type = replaceWith.type;\r\n const value = replaceWith.value;\r\n\r\n if (type === \"fs\") {\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n toReplace,\r\n value\r\n );\r\n } else if (type === \"vs\") {\r\n shader.vertexShader = shader.vertexShader.replace(\r\n toReplace,\r\n value\r\n );\r\n }\r\n } else if (replaceWith) {\r\n shader.vertexShader = shader.vertexShader.replace(\r\n toReplace,\r\n replaceWith\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n toReplace,\r\n replaceWith\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Extend the shaders\r\n shader.vertexShader = extendShader(\r\n shader.vertexShader,\r\n vertexShader,\r\n false\r\n );\r\n\r\n shader.fragmentShader = extendShader(\r\n shader.fragmentShader,\r\n fragmentShader,\r\n true\r\n );\r\n\r\n if (uniforms) {\r\n shader.uniforms = { ...shader.uniforms, ...self.uniforms };\r\n }\r\n\r\n self.uniforms = shader.uniforms;\r\n };\r\n\r\n const prevCacheKey = self.customProgramCacheKey;\r\n\r\n self.customProgramCacheKey = () => {\r\n return (\r\n (cacheKey?.() || hash((vertexShader || \"\") + (fragmentShader || \"\"))) +\r\n prevCacheKey?.call(self)\r\n );\r\n };\r\n\r\n self.needsUpdate = true;\r\n }\r\n}\r\n\r\nexport {\r\n type CSMPatchMap,\r\n type CSMProxy,\r\n type CustomShaderMaterialParameters,\r\n type MaterialConstructor,\r\n} from \"./types\";\r\n"],"names":["defaultCsmDefinitions","defaultCsmMainDefinitions","defaultVertDefinitions","defaultVertMain","defaultFragDefinitions","defaultFragMain","keywordMap","availabilityMap","defaultPatchMap","THREE","requiredPropsMap","sdbm","string","hash","i","h","isConstructor","f","err","deepMergeObjects","target","source","key","stripComments","str","stripNewLines","stripSpaces","isEmptyFunction","func","funcName","CustomShaderMaterial","baseMaterial","vertexShader","fragmentShader","uniforms","patchMap","cacheKey","opts","base","isEmptyOpts","extendedBase","mergedUniforms","_fs","_vs","self","prop","matchKeywords","keyword","matchKeyword","prevOnBeforeCompile","doesHavePreviousBeforeCompile","extendShader","prevShader","newShader","isFrag","mainBody","beforeMain","mainBodyRegex","_a","mainIndex","lastMainEndIndex","toAppend","regex","shader","renderer","mergedPatchMap","type","typeDefine","doesIncludeInVert","availableIn","toReplace","replaceWith","value","prevCacheKey"],"mappings":"gUAAaA,EAAmC;AAAA;AAAA;AAAA;AAAA;A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QA,CAAW,EACtB,CAACA,EAAY,SAASH,CAAI,EAC1BG,IAAgBH,GACpB,CACQ,QAAA,MACN,yBAAyBnB,CAAO,wBAAwBmB,CAAI,0BAAA,EAE9D,MACF,CAEM/B,MAAAA,EAAW8B,EAAelB,CAAO,EAEvC,UAAWuB,KAAanC,EAAU,CAC1B,MAAAoC,EAAcpC,EAASmC,CAAS,EAClC,GAAA,OAAOC,GAAgB,SAAU,CACnC,MAAML,EAAOK,EAAY,KACnBC,EAAQD,EAAY,MAEtBL,IAAS,KACJH,EAAA,eAAiBA,EAAO,eAAe,QAC5CO,EACAE,CAAA,EAEON,IAAS,OACXH,EAAA,aAAeA,EAAO,aAAa,QACxCO,EACAE,CAAA,QAGKD,IACFR,EAAA,aAAeA,EAAO,aAAa,QACxCO,EACAC,CAAA,EAEKR,EAAA,eAAiBA,EAAO,eAAe,QAC5CO,EACAC,CAAA,EAGN,CACF,CACF,CAGAR,EAAO,aAAeZ,EACpBY,EAAO,aACP/B,EACA,EAAA,EAGF+B,EAAO,eAAiBZ,EACtBY,EAAO,eACP9B,EACA,EAAA,EAGEC,IACF6B,EAAO,SAAW,CAAE,GAAGA,EAAO,SAAU,GAAGnB,EAAK,WAGlDA,EAAK,SAAWmB,EAAO,QAAA,EAGzB,MAAMU,EAAe7B,EAAK,sBAE1BA,EAAK,sBAAwB,MAExBR,GAAA,YAAAA,MAAgBvB,GAAMmB,GAAgB,KAAOC,GAAkB,GAAG,IACnEwC,GAAA,YAAAA,EAAc,KAAK7B,IAIvBA,EAAK,YAAc,EACrB,CACF"} \ No newline at end of file diff --git a/entry/es/react.js b/entry/es/react.js new file mode 100644 index 0000000..482fb2a --- /dev/null +++ b/entry/es/react.js @@ -0,0 +1,672 @@ +import * as W from "react"; +import Ce from "react"; +import ur from "./vanilla.js"; +var K = { exports: {} }, A = {}; +/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var Te; +function sr() { + if (Te) + return A; + Te = 1; + var T = Ce, E = Symbol.for("react.element"), m = Symbol.for("react.fragment"), g = Object.prototype.hasOwnProperty, O = T.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, C = { key: !0, ref: !0, __self: !0, __source: !0 }; + function w(_, l, R) { + var v, b = {}, P = null, $ = null; + R !== void 0 && (P = "" + R), l.key !== void 0 && (P = "" + l.key), l.ref !== void 0 && ($ = l.ref); + for (v in l) + g.call(l, v) && !C.hasOwnProperty(v) && (b[v] = l[v]); + if (_ && _.defaultProps) + for (v in l = _.defaultProps, l) + b[v] === void 0 && (b[v] = l[v]); + return { $$typeof: E, type: _, key: P, ref: $, props: b, _owner: O.current }; + } + return A.Fragment = m, A.jsx = w, A.jsxs = w, A; +} +var I = {}; +/** + * @license React + * react-jsx-runtime.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var Oe; +function fr() { + return Oe || (Oe = 1, process.env.NODE_ENV !== "production" && function() { + var T = Ce, E = Symbol.for("react.element"), m = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), C = Symbol.for("react.profiler"), w = Symbol.for("react.provider"), _ = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), b = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), $ = Symbol.for("react.offscreen"), Z = Symbol.iterator, we = "@@iterator"; + function Pe(e) { + if (e === null || typeof e != "object") + return null; + var r = Z && e[Z] || e[we]; + return typeof r == "function" ? r : null; + } + var j = T.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + function c(e) { + { + for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++) + t[n - 1] = arguments[n]; + Se("error", e, t); + } + } + function Se(e, r, t) { + { + var n = j.ReactDebugCurrentFrame, i = n.getStackAddendum(); + i !== "" && (r += "%s", t = t.concat([i])); + var u = t.map(function(o) { + return String(o); + }); + u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u); + } + } + var je = !1, xe = !1, ke = !1, De = !1, Fe = !1, Q; + Q = Symbol.for("react.module.reference"); + function Ae(e) { + return !!(typeof e == "string" || typeof e == "function" || e === g || e === C || Fe || e === O || e === R || e === v || De || e === $ || je || xe || ke || typeof e == "object" && e !== null && (e.$$typeof === P || e.$$typeof === b || e.$$typeof === w || e.$$typeof === _ || e.$$typeof === l || // This needs to include all possible module reference object + // types supported by any Flight configuration anywhere since + // we don't know which Flight build this will end up being used + // with. + e.$$typeof === Q || e.getModuleId !== void 0)); + } + function Ie(e, r, t) { + var n = e.displayName; + if (n) + return n; + var i = r.displayName || r.name || ""; + return i !== "" ? t + "(" + i + ")" : t; + } + function ee(e) { + return e.displayName || "Context"; + } + function y(e) { + if (e == null) + return null; + if (typeof e.tag == "number" && c("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function") + return e.displayName || e.name || null; + if (typeof e == "string") + return e; + switch (e) { + case g: + return "Fragment"; + case m: + return "Portal"; + case C: + return "Profiler"; + case O: + return "StrictMode"; + case R: + return "Suspense"; + case v: + return "SuspenseList"; + } + if (typeof e == "object") + switch (e.$$typeof) { + case _: + var r = e; + return ee(r) + ".Consumer"; + case w: + var t = e; + return ee(t._context) + ".Provider"; + case l: + return Ie(e, e.render, "ForwardRef"); + case b: + var n = e.displayName || null; + return n !== null ? n : y(e.type) || "Memo"; + case P: { + var i = e, u = i._payload, o = i._init; + try { + return y(o(u)); + } catch { + return null; + } + } + } + return null; + } + var S = Object.assign, D = 0, re, te, ne, ae, oe, ie, ue; + function se() { + } + se.__reactDisabledLog = !0; + function We() { + { + if (D === 0) { + re = console.log, te = console.info, ne = console.warn, ae = console.error, oe = console.group, ie = console.groupCollapsed, ue = console.groupEnd; + var e = { + configurable: !0, + enumerable: !0, + value: se, + writable: !0 + }; + Object.defineProperties(console, { + info: e, + log: e, + warn: e, + error: e, + group: e, + groupCollapsed: e, + groupEnd: e + }); + } + D++; + } + } + function $e() { + { + if (D--, D === 0) { + var e = { + configurable: !0, + enumerable: !0, + writable: !0 + }; + Object.defineProperties(console, { + log: S({}, e, { + value: re + }), + info: S({}, e, { + value: te + }), + warn: S({}, e, { + value: ne + }), + error: S({}, e, { + value: ae + }), + group: S({}, e, { + value: oe + }), + groupCollapsed: S({}, e, { + value: ie + }), + groupEnd: S({}, e, { + value: ue + }) + }); + } + D < 0 && c("disabledDepth fell below zero. This is a bug in React. Please file an issue."); + } + } + var N = j.ReactCurrentDispatcher, B; + function Y(e, r, t) { + { + if (B === void 0) + try { + throw Error(); + } catch (i) { + var n = i.stack.trim().match(/\n( *(at )?)/); + B = n && n[1] || ""; + } + return ` +` + B + e; + } + } + var q = !1, L; + { + var Ye = typeof WeakMap == "function" ? WeakMap : Map; + L = new Ye(); + } + function fe(e, r) { + if (!e || q) + return ""; + { + var t = L.get(e); + if (t !== void 0) + return t; + } + var n; + q = !0; + var i = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var u; + u = N.current, N.current = null, We(); + try { + if (r) { + var o = function() { + throw Error(); + }; + if (Object.defineProperty(o.prototype, "props", { + set: function() { + throw Error(); + } + }), typeof Reflect == "object" && Reflect.construct) { + try { + Reflect.construct(o, []); + } catch (h) { + n = h; + } + Reflect.construct(e, [], o); + } else { + try { + o.call(); + } catch (h) { + n = h; + } + e.call(o.prototype); + } + } else { + try { + throw Error(); + } catch (h) { + n = h; + } + e(); + } + } catch (h) { + if (h && n && typeof h.stack == "string") { + for (var a = h.stack.split(` +`), d = n.stack.split(` +`), s = a.length - 1, f = d.length - 1; s >= 1 && f >= 0 && a[s] !== d[f]; ) + f--; + for (; s >= 1 && f >= 0; s--, f--) + if (a[s] !== d[f]) { + if (s !== 1 || f !== 1) + do + if (s--, f--, f < 0 || a[s] !== d[f]) { + var p = ` +` + a[s].replace(" at new ", " at "); + return e.displayName && p.includes("") && (p = p.replace("", e.displayName)), typeof e == "function" && L.set(e, p), p; + } + while (s >= 1 && f >= 0); + break; + } + } + } finally { + q = !1, N.current = u, $e(), Error.prepareStackTrace = i; + } + var k = e ? e.displayName || e.name : "", he = k ? Y(k) : ""; + return typeof e == "function" && L.set(e, he), he; + } + function Le(e, r, t) { + return fe(e, !1); + } + function Me(e) { + var r = e.prototype; + return !!(r && r.isReactComponent); + } + function M(e, r, t) { + if (e == null) + return ""; + if (typeof e == "function") + return fe(e, Me(e)); + if (typeof e == "string") + return Y(e); + switch (e) { + case R: + return Y("Suspense"); + case v: + return Y("SuspenseList"); + } + if (typeof e == "object") + switch (e.$$typeof) { + case l: + return Le(e.render); + case b: + return M(e.type, r, t); + case P: { + var n = e, i = n._payload, u = n._init; + try { + return M(u(i), r, t); + } catch { + } + } + } + return ""; + } + var U = Object.prototype.hasOwnProperty, le = {}, ce = j.ReactDebugCurrentFrame; + function V(e) { + if (e) { + var r = e._owner, t = M(e.type, e._source, r ? r.type : null); + ce.setExtraStackFrame(t); + } else + ce.setExtraStackFrame(null); + } + function Ue(e, r, t, n, i) { + { + var u = Function.call.bind(U); + for (var o in e) + if (u(e, o)) { + var a = void 0; + try { + if (typeof e[o] != "function") { + var d = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); + throw d.name = "Invariant Violation", d; + } + a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); + } catch (s) { + a = s; + } + a && !(a instanceof Error) && (V(i), c("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), V(null)), a instanceof Error && !(a.message in le) && (le[a.message] = !0, V(i), c("Failed %s type: %s", t, a.message), V(null)); + } + } + } + var Ve = Array.isArray; + function J(e) { + return Ve(e); + } + function Ne(e) { + { + var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object"; + return t; + } + } + function Be(e) { + try { + return de(e), !1; + } catch { + return !0; + } + } + function de(e) { + return "" + e; + } + function ve(e) { + if (Be(e)) + return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ne(e)), de(e); + } + var F = j.ReactCurrentOwner, qe = { + key: !0, + ref: !0, + __self: !0, + __source: !0 + }, pe, Ee, G; + G = {}; + function Je(e) { + if (U.call(e, "ref")) { + var r = Object.getOwnPropertyDescriptor(e, "ref").get; + if (r && r.isReactWarning) + return !1; + } + return e.ref !== void 0; + } + function Ge(e) { + if (U.call(e, "key")) { + var r = Object.getOwnPropertyDescriptor(e, "key").get; + if (r && r.isReactWarning) + return !1; + } + return e.key !== void 0; + } + function ze(e, r) { + if (typeof e.ref == "string" && F.current && r && F.current.stateNode !== r) { + var t = y(F.current.type); + G[t] || (c('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', y(F.current.type), e.ref), G[t] = !0); + } + } + function He(e, r) { + { + var t = function() { + pe || (pe = !0, c("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r)); + }; + t.isReactWarning = !0, Object.defineProperty(e, "key", { + get: t, + configurable: !0 + }); + } + } + function Xe(e, r) { + { + var t = function() { + Ee || (Ee = !0, c("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r)); + }; + t.isReactWarning = !0, Object.defineProperty(e, "ref", { + get: t, + configurable: !0 + }); + } + } + var Ke = function(e, r, t, n, i, u, o) { + var a = { + // This tag allows us to uniquely identify this as a React Element + $$typeof: E, + // Built-in properties that belong on the element + type: e, + key: r, + ref: t, + props: o, + // Record the component responsible for creating this element. + _owner: u + }; + return a._store = {}, Object.defineProperty(a._store, "validated", { + configurable: !1, + enumerable: !1, + writable: !0, + value: !1 + }), Object.defineProperty(a, "_self", { + configurable: !1, + enumerable: !1, + writable: !1, + value: n + }), Object.defineProperty(a, "_source", { + configurable: !1, + enumerable: !1, + writable: !1, + value: i + }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a; + }; + function Ze(e, r, t, n, i) { + { + var u, o = {}, a = null, d = null; + t !== void 0 && (ve(t), a = "" + t), Ge(r) && (ve(r.key), a = "" + r.key), Je(r) && (d = r.ref, ze(r, i)); + for (u in r) + U.call(r, u) && !qe.hasOwnProperty(u) && (o[u] = r[u]); + if (e && e.defaultProps) { + var s = e.defaultProps; + for (u in s) + o[u] === void 0 && (o[u] = s[u]); + } + if (a || d) { + var f = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; + a && He(o, f), d && Xe(o, f); + } + return Ke(e, a, d, i, n, F.current, o); + } + } + var z = j.ReactCurrentOwner, Re = j.ReactDebugCurrentFrame; + function x(e) { + if (e) { + var r = e._owner, t = M(e.type, e._source, r ? r.type : null); + Re.setExtraStackFrame(t); + } else + Re.setExtraStackFrame(null); + } + var H; + H = !1; + function X(e) { + return typeof e == "object" && e !== null && e.$$typeof === E; + } + function me() { + { + if (z.current) { + var e = y(z.current.type); + if (e) + return ` + +Check the render method of \`` + e + "`."; + } + return ""; + } + } + function Qe(e) { + return ""; + } + var ge = {}; + function er(e) { + { + var r = me(); + if (!r) { + var t = typeof e == "string" ? e : e.displayName || e.name; + t && (r = ` + +Check the top-level render call using <` + t + ">."); + } + return r; + } + } + function _e(e, r) { + { + if (!e._store || e._store.validated || e.key != null) + return; + e._store.validated = !0; + var t = er(r); + if (ge[t]) + return; + ge[t] = !0; + var n = ""; + e && e._owner && e._owner !== z.current && (n = " It was passed a child from " + y(e._owner.type) + "."), x(e), c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), x(null); + } + } + function be(e, r) { + { + if (typeof e != "object") + return; + if (J(e)) + for (var t = 0; t < e.length; t++) { + var n = e[t]; + X(n) && _e(n, r); + } + else if (X(e)) + e._store && (e._store.validated = !0); + else if (e) { + var i = Pe(e); + if (typeof i == "function" && i !== e.entries) + for (var u = i.call(e), o; !(o = u.next()).done; ) + X(o.value) && _e(o.value, r); + } + } + } + function rr(e) { + { + var r = e.type; + if (r == null || typeof r == "string") + return; + var t; + if (typeof r == "function") + t = r.propTypes; + else if (typeof r == "object" && (r.$$typeof === l || // Note: Memo only checks outer props here. + // Inner props are checked in the reconciler. + r.$$typeof === b)) + t = r.propTypes; + else + return; + if (t) { + var n = y(r); + Ue(t, e.props, "prop", n, e); + } else if (r.PropTypes !== void 0 && !H) { + H = !0; + var i = y(r); + c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown"); + } + typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); + } + } + function tr(e) { + { + for (var r = Object.keys(e.props), t = 0; t < r.length; t++) { + var n = r[t]; + if (n !== "children" && n !== "key") { + x(e), c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), x(null); + break; + } + } + e.ref !== null && (x(e), c("Invalid attribute `ref` supplied to `React.Fragment`."), x(null)); + } + } + function ye(e, r, t, n, i, u) { + { + var o = Ae(e); + if (!o) { + var a = ""; + (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); + var d = Qe(); + d ? a += d : a += me(); + var s; + e === null ? s = "null" : J(e) ? s = "array" : e !== void 0 && e.$$typeof === E ? (s = "<" + (y(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", s, a); + } + var f = Ze(e, r, t, i, u); + if (f == null) + return f; + if (o) { + var p = r.children; + if (p !== void 0) + if (n) + if (J(p)) { + for (var k = 0; k < p.length; k++) + be(p[k], e); + Object.freeze && Object.freeze(p); + } else + c("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); + else + be(p, e); + } + return e === g ? tr(f) : rr(f), f; + } + } + function nr(e, r, t) { + return ye(e, r, t, !0); + } + function ar(e, r, t) { + return ye(e, r, t, !1); + } + var or = ar, ir = nr; + I.Fragment = g, I.jsx = or, I.jsxs = ir; + }()), I; +} +process.env.NODE_ENV === "production" ? K.exports = sr() : K.exports = fr(); +var lr = K.exports; +function cr(T, E) { + const m = W.useRef(!1); + W.useEffect(() => { + if (m.current) + return T(); + m.current = !0; + }, E); +} +function dr({ + baseMaterial: T, + vertexShader: E, + fragmentShader: m, + uniforms: g, + cacheKey: O, + patchMap: C, + attach: w, + ..._ +}, l) { + const R = W.useMemo(() => new ur({ + baseMaterial: T, + vertexShader: E, + fragmentShader: m, + uniforms: g, + cacheKey: O, + patchMap: C, + ..._ + }), [T]); + return cr(() => { + R.update({ + vertexShader: E, + fragmentShader: m, + uniforms: g, + patchMap: C, + cacheKey: O + }); + }, [E, m, g, C, O]), W.useEffect(() => () => R.dispose(), [R]), /* @__PURE__ */ lr.jsx( + "primitive", + { + ref: l, + attach: w ?? "material", + object: R, + ..._ + } + ); +} +const Er = W.forwardRef(dr); +export { + Er as default +}; +//# sourceMappingURL=react.js.map diff --git a/entry/es/react.js.map b/entry/es/react.js.map new file mode 100644 index 0000000..47d3c74 --- /dev/null +++ b/entry/es/react.js.map @@ -0,0 +1 @@ +{"version":3,"file":"react.js","sources":["../../../node_modules/react/cjs/react-jsx-runtime.production.min.js","../../../node_modules/react/cjs/react-jsx-runtime.development.js","../../../node_modules/react/jsx-runtime.js","../../../src/React/index.tsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n'use strict';\n\nvar React = require('react');\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar assign = Object.assign;\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('')) {\n _frame = _frame.replace('', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nvar ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown;\nvar specialPropRefWarningShown;\nvar didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config, self) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingKey = function () {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n }\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingRef = function () {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * https://github.com/reactjs/rfcs/pull/107\n * @param {*} type\n * @param {object} props\n * @param {string} key\n */\n\nfunction jsxDEV(type, config, maybeKey, source, self) {\n {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null; // Currently, key can be spread in as a prop. This causes a potential\n // issue if key is also explicitly declared (ie.
\n // or
). We want to deprecate key spread,\n // but as an intermediary step, we will use jsxDEV for everything except\n //
, because we aren't currently able to tell if\n // key is explicitly declared to be undefined or not.\n\n if (maybeKey !== undefined) {\n {\n checkKeyStringCoercion(maybeKey);\n }\n\n key = '' + maybeKey;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n if (hasValidRef(config)) {\n ref = config.ref;\n warnIfStringRefCannotBeAutoConverted(config, self);\n } // Remaining properties are added to a new props object\n\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n }\n}\n\nvar ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\n\nfunction isValidElement(object) {\n {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n }\n}\n\nfunction getDeclarationErrorAddendum() {\n {\n if (ReactCurrentOwner$1.current) {\n var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n }\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n }\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n }\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\n\nfunction jsxWithValidation(type, props, key, isStaticChildren, source, self) {\n {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendum(source);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n\n var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n var children = props.children;\n\n if (children !== undefined) {\n if (isStaticChildren) {\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n validateChildKeys(children[i], type);\n }\n\n if (Object.freeze) {\n Object.freeze(children);\n }\n } else {\n error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');\n }\n } else {\n validateChildKeys(children, type);\n }\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n }\n} // These two functions exist to still get child warnings in dev\n// even with the prod transform. This means that jsxDEV is purely\n// opt-in behavior for better messages but that we won't stop\n// giving you warnings if you use production apis.\n\nfunction jsxWithValidationStatic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, true);\n }\n}\nfunction jsxWithValidationDynamic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, false);\n }\n}\n\nvar jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.\n// for now we can ship identical prod functions\n\nvar jsxs = jsxWithValidationStatic ;\n\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsx;\nexports.jsxs = jsxs;\n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","import { AttachType } from \"@react-three/fiber/dist/declarations/src/core/renderer\";\r\nimport * as React from \"react\";\r\nimport { Material } from \"three\";\r\nimport CustomShaderMaterialImpl, { MaterialConstructor } from \"../index\";\r\nimport { CustomShaderMaterialProps } from \"./types\";\r\n\r\nfunction useDidUpdateEffect(\r\n fn: (...opts: any[]) => any,\r\n inputs: React.DependencyList\r\n) {\r\n const didMountRef = React.useRef(false);\r\n\r\n React.useEffect(() => {\r\n if (didMountRef.current) {\r\n return fn();\r\n }\r\n didMountRef.current = true;\r\n }, inputs);\r\n}\r\n\r\nfunction CustomShaderMaterial(\r\n {\r\n baseMaterial,\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n cacheKey,\r\n patchMap,\r\n attach,\r\n ...opts\r\n }: CustomShaderMaterialProps,\r\n ref: React.Ref>\r\n) {\r\n const material = React.useMemo(() => {\r\n return new CustomShaderMaterialImpl({\r\n baseMaterial,\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n cacheKey,\r\n patchMap,\r\n ...opts,\r\n });\r\n }, [baseMaterial]);\r\n\r\n useDidUpdateEffect(() => {\r\n material.update({\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n patchMap,\r\n cacheKey,\r\n });\r\n }, [vertexShader, fragmentShader, uniforms, patchMap, cacheKey]);\r\n\r\n React.useEffect(() => () => material.dispose(), [material]);\r\n\r\n return (\r\n \r\n );\r\n}\r\n\r\n// export default React.forwardRef(CustomShaderMaterial) as <\r\n// T extends MaterialConstructor\r\n// >(\r\n// props: CustomShaderMaterialProps & { ref?: React.Ref> }\r\n// ) => React.ReactElement;\r\n\r\nexport default React.forwardRef(CustomShaderMaterial) as <\r\n T extends MaterialConstructor = typeof Material\r\n>(\r\n props: CustomShaderMaterialProps & {\r\n ref?: React.Ref>;\r\n attach?: AttachType;\r\n }\r\n) => React.ReactElement;\r\n\r\nexport { type CustomShaderMaterialProps } from \"./types\";\r\n"],"names":["f","require$$0","k","l","m","n","p","q","c","a","g","b","d","e","h","reactJsxRuntime_production_min","React","REACT_ELEMENT_TYPE","REACT_PORTAL_TYPE","REACT_FRAGMENT_TYPE","REACT_STRICT_MODE_TYPE","REACT_PROFILER_TYPE","REACT_PROVIDER_TYPE","REACT_CONTEXT_TYPE","REACT_FORWARD_REF_TYPE","REACT_SUSPENSE_TYPE","REACT_SUSPENSE_LIST_TYPE","REACT_MEMO_TYPE","REACT_LAZY_TYPE","REACT_OFFSCREEN_TYPE","MAYBE_ITERATOR_SYMBOL","FAUX_ITERATOR_SYMBOL","getIteratorFn","maybeIterable","maybeIterator","ReactSharedInternals","error","format","_len2","args","_key2","printWarning","level","ReactDebugCurrentFrame","stack","argsWithFormat","item","enableScopeAPI","enableCacheElement","enableTransitionTracing","enableLegacyHidden","enableDebugTracing","REACT_MODULE_REFERENCE","isValidElementType","type","getWrappedName","outerType","innerType","wrapperName","displayName","functionName","getContextName","getComponentNameFromType","context","provider","outerName","lazyComponent","payload","init","assign","disabledDepth","prevLog","prevInfo","prevWarn","prevError","prevGroup","prevGroupCollapsed","prevGroupEnd","disabledLog","disableLogs","props","reenableLogs","ReactCurrentDispatcher","prefix","describeBuiltInComponentFrame","name","source","ownerFn","x","match","reentry","componentFrameCache","PossiblyWeakMap","describeNativeComponentFrame","fn","construct","frame","control","previousPrepareStackTrace","previousDispatcher","Fake","sample","sampleLines","controlLines","_frame","syntheticFrame","describeFunctionComponentFrame","shouldConstruct","Component","prototype","describeUnknownElementTypeFrameInDEV","hasOwnProperty","loggedTypeFailures","setCurrentlyValidatingElement","element","owner","checkPropTypes","typeSpecs","values","location","componentName","has","typeSpecName","error$1","err","ex","isArrayImpl","isArray","typeName","value","hasToStringTag","willCoercionThrow","testStringCoercion","checkKeyStringCoercion","ReactCurrentOwner","RESERVED_PROPS","specialPropKeyWarningShown","specialPropRefWarningShown","didWarnAboutStringRefs","hasValidRef","config","getter","hasValidKey","warnIfStringRefCannotBeAutoConverted","self","defineKeyPropWarningGetter","warnAboutAccessingKey","defineRefPropWarningGetter","warnAboutAccessingRef","ReactElement","key","ref","jsxDEV","maybeKey","propName","defaultProps","ReactCurrentOwner$1","ReactDebugCurrentFrame$1","setCurrentlyValidatingElement$1","propTypesMisspellWarningShown","isValidElement","object","getDeclarationErrorAddendum","getSourceInfoErrorAddendum","ownerHasKeyUseWarning","getCurrentComponentErrorInfo","parentType","info","parentName","validateExplicitKey","currentComponentErrorInfo","childOwner","validateChildKeys","node","i","child","iteratorFn","iterator","step","validatePropTypes","propTypes","_name","validateFragmentProps","fragment","keys","jsxWithValidation","isStaticChildren","validType","sourceInfo","typeString","children","jsxWithValidationStatic","jsxWithValidationDynamic","jsx","jsxs","reactJsxRuntime_development","jsxRuntimeModule","require$$1","useDidUpdateEffect","inputs","didMountRef","CustomShaderMaterial","baseMaterial","vertexShader","fragmentShader","uniforms","cacheKey","patchMap","attach","opts","material","CustomShaderMaterialImpl","index"],"mappings":";;;;;;;;;;;;;;;;;;AASa,MAAIA,IAAEC,IAAiBC,IAAE,OAAO,IAAI,eAAe,GAAEC,IAAE,OAAO,IAAI,gBAAgB,GAAEC,IAAE,OAAO,UAAU,gBAAeC,IAAEL,EAAE,mDAAmD,mBAAkBM,IAAE,EAAC,KAAI,IAAG,KAAI,IAAG,QAAO,IAAG,UAAS,GAAE;AAClP,WAASC,EAAEC,GAAEC,GAAEC,GAAE;AAAC,QAAIC,GAAEC,IAAE,IAAGC,IAAE,MAAKC,IAAE;AAAK,IAASJ,MAAT,WAAaG,IAAE,KAAGH,IAAYD,EAAE,QAAX,WAAiBI,IAAE,KAAGJ,EAAE,MAAcA,EAAE,QAAX,WAAiBK,IAAEL,EAAE;AAAK,SAAIE,KAAKF;AAAE,MAAAL,EAAE,KAAKK,GAAEE,CAAC,KAAG,CAACL,EAAE,eAAeK,CAAC,MAAIC,EAAED,CAAC,IAAEF,EAAEE,CAAC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":[0,1,2]} \ No newline at end of file diff --git a/entry/es/vanilla.js b/entry/es/vanilla.js new file mode 100644 index 0000000..e6cff41 --- /dev/null +++ b/entry/es/vanilla.js @@ -0,0 +1,555 @@ +import * as v from "three"; +const D = ( + /* glsl */ + ` + +#ifdef IS_VERTEX + vec3 csm_Position; + vec4 csm_PositionRaw; + vec3 csm_Normal; + + // csm_PointSize + #ifdef IS_POINTSMATERIAL + float csm_PointSize; + #endif +#else + vec4 csm_DiffuseColor; + vec4 csm_FragColor; + float csm_FragColorInfluence; + + // csm_Emissive, csm_Roughness, csm_Metalness + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL + vec3 csm_Emissive; + float csm_Roughness; + float csm_Metalness; + float csm_Iridescence; + + #if defined IS_MESHPHYSICALMATERIAL + float csm_Clearcoat; + float csm_ClearcoatRoughness; + vec3 csm_ClearcoatNormal; + float csm_Transmission; + float csm_Thickness; + #endif + #endif + + // csm_AO + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL + float csm_AO; + #endif + + // csm_Bump + #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL + vec3 csm_Bump; + #endif + + float csm_DepthAlpha; +#endif +` +), x = ( + /* glsl */ + ` + +#ifdef IS_VERTEX + // csm_Position & csm_PositionRaw + #ifdef IS_UNKNOWN + csm_Position = vec3(0.0); + csm_PositionRaw = vec4(0.0); + csm_Normal = vec3(0.0); + #else + csm_Position = position; + csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.); + csm_Normal = normal; + #endif + + // csm_PointSize + #ifdef IS_POINTSMATERIAL + csm_PointSize = size; + #endif +#else + csm_FragColorInfluence = 0.0; + + // csm_DiffuseColor & csm_FragColor + #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHDISTANCEMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL + csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0); + csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0); + #else + #ifdef USE_MAP + vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv); + + #ifdef DECODE_VIDEO_TEXTURE + // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved) + _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w); + #endif + + csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor; + csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor; + #else + csm_DiffuseColor = vec4(diffuse, opacity); + csm_FragColor = vec4(diffuse, opacity); + #endif + #endif + + // csm_Emissive, csm_Roughness, csm_Metalness + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL + csm_Emissive = emissive; + csm_Roughness = roughness; + csm_Metalness = metalness; + + #ifdef USE_IRIDESCENCE + csm_Iridescence = iridescence; + #else + csm_Iridescence = 0.0; + #endif + + #if defined IS_MESHPHYSICALMATERIAL + #ifdef USE_CLEARCOAT + csm_Clearcoat = clearcoat; + csm_ClearcoatRoughness = clearcoatRoughness; + #else + csm_Clearcoat = 0.0; + csm_ClearcoatRoughness = 0.0; + #endif + + #ifdef USE_TRANSMISSION + csm_Transmission = transmission; + csm_Thickness = thickness; + #else + csm_Transmission = 0.0; + csm_Thickness = 0.0; + #endif + #endif + #endif + + // csm_AO + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL + csm_AO = 0.0; + #endif + + // csm_Bump + #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL + csm_Bump = vec3(0.0); + #endif + + csm_DepthAlpha = 1.0; +#endif +` +), O = ( + /* glsl */ + ` + varying mat4 csm_internal_vModelViewMatrix; +` +), y = ( + /* glsl */ + ` + csm_internal_vModelViewMatrix = modelViewMatrix; +` +), b = ( + /* glsl */ + ` + varying mat4 csm_internal_vModelViewMatrix; +` +), w = ( + /* glsl */ + ` + +` +), e = { + // PBR + diffuse: "csm_DiffuseColor", + // Color + alpha + normal: "csm_Normal", + // Normal + roughness: "csm_Roughness", + // Roughness + metalness: "csm_Metalness", + // Metalness + emissive: "csm_Emissive", + // Emissive + ao: "csm_AO", + // AO + bump: "csm_Bump", + // Bump + clearcoat: "csm_Clearcoat", + // Clearcoat factor + clearcoatRoughness: "csm_ClearcoatRoughness", + // Clearcoat roughness + clearcoatNormal: "csm_ClearcoatNormal", + // Clearcoat normals + transmission: "csm_Transmission", + // Transmission + thickness: "csm_Thickness", + // Thickness + iridescence: "csm_Iridescence", + // Iridescence + // Extras + pointSize: "csm_PointSize", + fragColor: "csm_FragColor", + depthAlpha: "csm_DepthAlpha", + // Depth + fragColorInfluence: "csm_FragColorInfluence", + // Unlit factor + // Vert + position: "csm_Position", + positionRaw: "csm_PositionRaw" +}, k = { + [`${e.position}`]: "*", + [`${e.positionRaw}`]: "*", + [`${e.normal}`]: "*", + [`${e.depthAlpha}`]: "*", + [`${e.pointSize}`]: ["PointsMaterial"], + [`${e.diffuse}`]: "*", + [`${e.fragColor}`]: "*", + [`${e.fragColorInfluence}`]: ["*"], + [`${e.emissive}`]: ["MeshStandardMaterial", "MeshPhysicalMaterial"], + [`${e.roughness}`]: ["MeshStandardMaterial", "MeshPhysicalMaterial"], + [`${e.metalness}`]: ["MeshStandardMaterial", "MeshPhysicalMaterial"], + [`${e.iridescence}`]: [ + "MeshStandardMaterial", + "MeshPhysicalMaterial" + ], + [`${e.ao}`]: [ + "MeshStandardMaterial", + "MeshPhysicalMaterial", + "MeshBasicMaterial", + "MeshLambertMaterial", + "MeshPhongMaterial", + "MeshToonMaterial" + ], + [`${e.bump}`]: [ + "MeshLambertMaterial", + "MeshMatcapMaterial", + "MeshNormalMaterial", + "MeshPhongMaterial", + "MeshPhysicalMaterial", + "MeshStandardMaterial", + "MeshToonMaterial", + "ShadowMaterial" + ], + [`${e.clearcoat}`]: ["MeshPhysicalMaterial"], + [`${e.clearcoatRoughness}`]: ["MeshPhysicalMaterial"], + [`${e.clearcoatNormal}`]: ["MeshPhysicalMaterial"], + [`${e.transmission}`]: ["MeshPhysicalMaterial"], + [`${e.thickness}`]: ["MeshPhysicalMaterial"] +}, F = { + // VERT + "*": { + "#include ": v.ShaderChunk.lights_physical_fragment, + "#include ": v.ShaderChunk.transmission_fragment + }, + [`${e.normal}`]: { + "#include ": ` + vec3 objectNormal = ${e.normal}; + #ifdef USE_TANGENT + vec3 objectTangent = vec3( tangent.xyz ); + #endif + ` + }, + [`${e.position}`]: { + "#include ": ` + vec3 transformed = ${e.position}; + ` + }, + [`${e.positionRaw}`]: { + "#include ": ` + vec4 csm_internal_positionUnprojected = ${e.positionRaw}; + mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix; + #ifdef USE_INSTANCING + csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix; + #endif + csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected; + vec3 transformed = csm_internal_positionUnprojected.xyz; + ` + }, + [`${e.pointSize}`]: { + "gl_PointSize = size;": ` + gl_PointSize = ${e.pointSize}; + ` + }, + // FRAG + [`${e.diffuse}`]: { + "#include ": ` + #include + diffuseColor = ${e.diffuse}; + ` + }, + [`${e.fragColor}`]: { + "#include ": ` + #include + gl_FragColor = mix(gl_FragColor, ${e.fragColor}, ${e.fragColorInfluence}); + ` + }, + [`${e.emissive}`]: { + "vec3 totalEmissiveRadiance = emissive;": ` + vec3 totalEmissiveRadiance = ${e.emissive}; + ` + }, + [`${e.roughness}`]: { + "#include ": ` + #include + roughnessFactor = ${e.roughness}; + ` + }, + [`${e.metalness}`]: { + "#include ": ` + #include + metalnessFactor = ${e.metalness}; + ` + }, + [`${e.ao}`]: { + "#include ": ` + #include + reflectedLight.indirectDiffuse *= 1. - ${e.ao}; + ` + }, + [`${e.bump}`]: { + "#include ": ` + #include + + vec3 csm_internal_orthogonal = ${e.bump} - (dot(${e.bump}, normal) * normal); + vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal; + normal = normalize(normal - csm_internal_projectedbump); + ` + }, + [`${e.depthAlpha}`]: { + "gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );": ` + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * ${e.depthAlpha} ); + `, + "gl_FragColor = packDepthToRGBA( fragCoordZ );": ` + if(${e.depthAlpha} > 0.0) discard; + gl_FragColor = packDepthToRGBA( dist ); + `, + "gl_FragColor = packDepthToRGBA( dist );": ` + if(${e.depthAlpha} > 0.0) discard; + gl_FragColor = packDepthToRGBA( dist ); + ` + }, + [`${e.clearcoat}`]: { + "material.clearcoat = clearcoat;": `material.clearcoat = ${e.clearcoat};` + }, + [`${e.clearcoatRoughness}`]: { + "material.clearcoatRoughness = clearcoatRoughness;": `material.clearcoatRoughness = ${e.clearcoatRoughness};` + }, + [`${e.clearcoatNormal}`]: { + "#include ": ` + vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal); + vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal; + vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump); + ` + }, + [`${e.transmission}`]: { + "material.transmission = transmission;": ` + material.transmission = ${e.transmission}; + ` + }, + [`${e.thickness}`]: { + "material.thickness = thickness;": ` + material.thickness = ${e.thickness}; + ` + }, + [`${e.iridescence}`]: { + "material.iridescence = iridescence;": ` + material.iridescence = ${e.iridescence}; + ` + } +}, B = { + clearcoat: [ + e.clearcoat, + e.clearcoatNormal, + e.clearcoatRoughness + ], + transmission: [e.transmission], + iridescence: [e.iridescence] +}; +function j(n) { + let i = 0; + for (let d = 0; d < n.length; d++) + i = n.charCodeAt(d) + (i << 6) + (i << 16) - i; + const c = i >>> 0; + return String(c); +} +function z(n) { + try { + new n(); + } catch (i) { + if (i.message.indexOf("is not a constructor") >= 0) + return !1; + } + return !0; +} +function H(n, i) { + for (const c in i) + i[c] instanceof Object && Object.assign(i[c], H(n[c], i[c])); + return Object.assign(n || {}, i), n; +} +function P(n) { + return n.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, ""); +} +function U(n) { + return n.replace(/\n/g, ""); +} +function V(n) { + return n.replace(/\s/g, ""); +} +function G(n) { + const i = n.name; + return V(U(n.toString())) === `${i}(){}`; +} +class Y extends v.Material { + constructor({ + baseMaterial: i, + vertexShader: c, + fragmentShader: M, + uniforms: d, + patchMap: R, + cacheKey: _, + ...m + }) { + if (!i) + throw new Error("CustomShaderMaterial: baseMaterial is required."); + let s; + if (z(i)) { + const l = Object.keys(m).length === 0; + s = new i(l ? void 0 : m); + } else + s = i, Object.assign(s, m); + if (["ShaderMaterial", "RawShaderMaterial"].includes(s.type)) + throw new Error( + `CustomShaderMaterial does not support ${s.type} as a base material.` + ); + super(), this.uniforms = {}, this.vertexShader = "", this.fragmentShader = ""; + const t = s; + t.name = `CustomShaderMaterial<${s.name}>`, t.update = this.update.bind(t), t.__csm = { prevOnBeforeCompile: s.onBeforeCompile }; + const a = { ...t.uniforms || {}, ...d || {} }; + return t.uniforms = this.uniforms = a, t.vertexShader = this.vertexShader = c || "", t.fragmentShader = this.fragmentShader = M || "", t.update({ + fragmentShader: t.fragmentShader, + vertexShader: t.vertexShader, + uniforms: t.uniforms, + patchMap: R, + cacheKey: _ + }), t; + } + update({ + fragmentShader: i, + vertexShader: c, + uniforms: M, + cacheKey: d, + patchMap: R + }) { + const _ = P(c || ""), m = P(i || ""), s = this; + M && (s.uniforms = M), c && (s.vertexShader = c), i && (s.fragmentShader = i), Object.entries(B).forEach(([a, l]) => { + for (const h in l) { + const r = l[h]; + (m && m.includes(r) || _ && _.includes(r)) && (s[a] || (s[a] = 1)); + } + }); + const u = s.__csm.prevOnBeforeCompile, t = !G(u), C = (a, l, h) => { + var A; + let r, f = ""; + if (l) { + const o = /void\s+main\s*\(\s*\)[^{]*{((?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{[^{}]*})*})*})*})*})/gm; + r = (A = l.matchAll(o).next().value) == null ? void 0 : A[1], r && (r = r.slice(0, -1)); + const T = l.indexOf("void main() {"); + f = l.slice(0, T); + } + if (t) { + a = a.replace( + "void main() {", + ` + // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial + + ${f} + + void main() { + ` + ); + const o = a.lastIndexOf("//~CSM_MAIN_END"); + if (o !== -1) { + const I = ` + ${r ? `${r}` : ""} + //~CSM_MAIN_END + `; + a = a.slice(0, o) + I + a.slice(o); + } + } else { + const o = /void\s*main\s*\(\s*\)\s*{/gm; + a = a.replace( + o, + ` + // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial + + ${h ? b : O} + ${D} + + ${f} + + void main() { + ${x} + ${h ? w : y} + + ${r ? `${r}` : ""} + //~CSM_MAIN_END + ` + ); + } + return a; + }; + s.onBeforeCompile = (a, l) => { + u == null || u(a, l); + const r = H(F, R || {}), f = s.type, A = f ? `#define IS_${f.toUpperCase()}; +` : `#define IS_UNKNOWN; +`; + a.vertexShader = A + `#define IS_VERTEX +` + a.vertexShader, a.fragmentShader = A + `#define IS_FRAGMENT +` + a.fragmentShader; + for (const o in r) { + const I = o === "*" || _ && _.includes(o); + if (o === "*" || m && m.includes(o) || I) { + const p = k[o]; + if (p && p !== "*" && (Array.isArray(p) ? !p.includes(f) : p !== f)) { + console.error( + `CustomShaderMaterial: ${o} is not available in ${f}. Shader cannot compile.` + ); + return; + } + const $ = r[o]; + for (const g in $) { + const S = $[g]; + if (typeof S == "object") { + const N = S.type, L = S.value; + N === "fs" ? a.fragmentShader = a.fragmentShader.replace( + g, + L + ) : N === "vs" && (a.vertexShader = a.vertexShader.replace( + g, + L + )); + } else + S && (a.vertexShader = a.vertexShader.replace( + g, + S + ), a.fragmentShader = a.fragmentShader.replace( + g, + S + )); + } + } + } + a.vertexShader = C( + a.vertexShader, + _, + !1 + ), a.fragmentShader = C( + a.fragmentShader, + m, + !0 + ), M && (a.uniforms = { ...a.uniforms, ...s.uniforms }), s.uniforms = a.uniforms; + }; + const E = s.customProgramCacheKey; + s.customProgramCacheKey = () => ((d == null ? void 0 : d()) || j((_ || "") + (m || ""))) + (E == null ? void 0 : E.call(s)), s.needsUpdate = !0; + } +} +export { + Y as default +}; +//# sourceMappingURL=vanilla.js.map diff --git a/entry/es/vanilla.js.map b/entry/es/vanilla.js.map new file mode 100644 index 0000000..2f203ca --- /dev/null +++ b/entry/es/vanilla.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vanilla.js","sources":["../../../src/defaults.ts","../../../src/maps/keywordMap.ts","../../../src/maps/availabilityMap.ts","../../../src/maps/patchMap.ts","../../../src/maps/requiredPropsMap.ts","../../../src/sdbm.js","../../../src/utils.ts","../../../src/index.ts"],"sourcesContent":["export const defaultCsmDefinitions = /* glsl */ `\r\n \r\n#ifdef IS_VERTEX\r\n vec3 csm_Position;\r\n vec4 csm_PositionRaw;\r\n vec3 csm_Normal;\r\n\r\n // csm_PointSize\r\n #ifdef IS_POINTSMATERIAL\r\n float csm_PointSize;\r\n #endif\r\n#else\r\n vec4 csm_DiffuseColor;\r\n vec4 csm_FragColor;\r\n float csm_FragColorInfluence;\r\n\r\n // csm_Emissive, csm_Roughness, csm_Metalness\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\r\n vec3 csm_Emissive;\r\n float csm_Roughness;\r\n float csm_Metalness;\r\n float csm_Iridescence;\r\n \r\n #if defined IS_MESHPHYSICALMATERIAL\r\n float csm_Clearcoat;\r\n float csm_ClearcoatRoughness;\r\n vec3 csm_ClearcoatNormal;\r\n float csm_Transmission;\r\n float csm_Thickness;\r\n #endif\r\n #endif\r\n\r\n // csm_AO\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\r\n float csm_AO;\r\n #endif\r\n\r\n // csm_Bump\r\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \r\n vec3 csm_Bump;\r\n #endif\r\n\r\n float csm_DepthAlpha;\r\n#endif\r\n`;\r\n\r\nexport const defaultCsmMainDefinitions = /* glsl */ `\r\n\r\n#ifdef IS_VERTEX\r\n // csm_Position & csm_PositionRaw\r\n #ifdef IS_UNKNOWN\r\n csm_Position = vec3(0.0);\r\n csm_PositionRaw = vec4(0.0);\r\n csm_Normal = vec3(0.0);\r\n #else\r\n csm_Position = position;\r\n csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.);\r\n csm_Normal = normal;\r\n #endif\r\n\r\n // csm_PointSize\r\n #ifdef IS_POINTSMATERIAL\r\n csm_PointSize = size;\r\n #endif\r\n#else\r\n csm_FragColorInfluence = 0.0;\r\n\r\n // csm_DiffuseColor & csm_FragColor\r\n #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHDISTANCEMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL\r\n csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0);\r\n csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\r\n #else\r\n #ifdef USE_MAP\r\n vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv);\r\n\r\n #ifdef DECODE_VIDEO_TEXTURE\r\n // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)\r\n _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w);\r\n #endif\r\n\r\n csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\r\n csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor;\r\n #else\r\n csm_DiffuseColor = vec4(diffuse, opacity);\r\n csm_FragColor = vec4(diffuse, opacity);\r\n #endif\r\n #endif\r\n\r\n // csm_Emissive, csm_Roughness, csm_Metalness\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL\r\n csm_Emissive = emissive;\r\n csm_Roughness = roughness;\r\n csm_Metalness = metalness;\r\n\r\n #ifdef USE_IRIDESCENCE\r\n csm_Iridescence = iridescence;\r\n #else\r\n csm_Iridescence = 0.0;\r\n #endif\r\n\r\n #if defined IS_MESHPHYSICALMATERIAL\r\n #ifdef USE_CLEARCOAT\r\n csm_Clearcoat = clearcoat;\r\n csm_ClearcoatRoughness = clearcoatRoughness;\r\n #else\r\n csm_Clearcoat = 0.0;\r\n csm_ClearcoatRoughness = 0.0;\r\n #endif\r\n\r\n #ifdef USE_TRANSMISSION\r\n csm_Transmission = transmission;\r\n csm_Thickness = thickness;\r\n #else\r\n csm_Transmission = 0.0;\r\n csm_Thickness = 0.0;\r\n #endif\r\n #endif\r\n #endif\r\n\r\n // csm_AO\r\n #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL\r\n csm_AO = 0.0;\r\n #endif\r\n\r\n // csm_Bump\r\n #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL \r\n csm_Bump = vec3(0.0);\r\n #endif\r\n\r\n csm_DepthAlpha = 1.0;\r\n#endif\r\n`;\r\n\r\nexport const defaultVertDefinitions = /* glsl */ `\r\n varying mat4 csm_internal_vModelViewMatrix;\r\n`;\r\n\r\nexport const defaultVertMain = /* glsl */ `\r\n csm_internal_vModelViewMatrix = modelViewMatrix;\r\n`;\r\n\r\nexport const defaultFragDefinitions = /* glsl */ `\r\n varying mat4 csm_internal_vModelViewMatrix;\r\n`;\r\n\r\nexport const defaultFragMain = /* glsl */ `\r\n \r\n`;\r\n","export const keywordMap = {\r\n // PBR\r\n diffuse: \"csm_DiffuseColor\", // Color + alpha\r\n normal: \"csm_Normal\", // Normal\r\n roughness: \"csm_Roughness\", // Roughness\r\n metalness: \"csm_Metalness\", // Metalness\r\n emissive: \"csm_Emissive\", // Emissive\r\n ao: \"csm_AO\", // AO\r\n bump: \"csm_Bump\", // Bump\r\n clearcoat: \"csm_Clearcoat\", // Clearcoat factor\r\n clearcoatRoughness: \"csm_ClearcoatRoughness\", // Clearcoat roughness\r\n clearcoatNormal: \"csm_ClearcoatNormal\", // Clearcoat normals\r\n transmission: \"csm_Transmission\", // Transmission\r\n thickness: \"csm_Thickness\", // Thickness\r\n iridescence: \"csm_Iridescence\", // Iridescence\r\n\r\n // Extras\r\n pointSize: \"csm_PointSize\",\r\n fragColor: \"csm_FragColor\",\r\n depthAlpha: \"csm_DepthAlpha\", // Depth\r\n fragColorInfluence: \"csm_FragColorInfluence\", // Unlit factor\r\n\r\n // Vert\r\n position: \"csm_Position\",\r\n positionRaw: \"csm_PositionRaw\",\r\n};\r\n","import { keywordMap } from \"./keywordMap\";\r\n\r\n// Map of CSM keywords to the materials they are available in\r\n// Some keywords are only available in certain materials\r\nexport const availabilityMap = {\r\n [`${keywordMap.position}`]: \"*\",\r\n [`${keywordMap.positionRaw}`]: \"*\",\r\n [`${keywordMap.normal}`]: \"*\",\r\n [`${keywordMap.depthAlpha}`]: \"*\",\r\n [`${keywordMap.pointSize}`]: [\"PointsMaterial\"],\r\n\r\n [`${keywordMap.diffuse}`]: \"*\",\r\n [`${keywordMap.fragColor}`]: \"*\",\r\n [`${keywordMap.fragColorInfluence}`]: [\"*\"],\r\n [`${keywordMap.emissive}`]: [\"MeshStandardMaterial\", \"MeshPhysicalMaterial\"],\r\n [`${keywordMap.roughness}`]: [\"MeshStandardMaterial\", \"MeshPhysicalMaterial\"],\r\n [`${keywordMap.metalness}`]: [\"MeshStandardMaterial\", \"MeshPhysicalMaterial\"],\r\n [`${keywordMap.iridescence}`]: [\r\n \"MeshStandardMaterial\",\r\n \"MeshPhysicalMaterial\",\r\n ],\r\n [`${keywordMap.ao}`]: [\r\n \"MeshStandardMaterial\",\r\n \"MeshPhysicalMaterial\",\r\n \"MeshBasicMaterial\",\r\n \"MeshLambertMaterial\",\r\n \"MeshPhongMaterial\",\r\n \"MeshToonMaterial\",\r\n ],\r\n [`${keywordMap.bump}`]: [\r\n \"MeshLambertMaterial\",\r\n \"MeshMatcapMaterial\",\r\n \"MeshNormalMaterial\",\r\n \"MeshPhongMaterial\",\r\n \"MeshPhysicalMaterial\",\r\n \"MeshStandardMaterial\",\r\n \"MeshToonMaterial\",\r\n \"ShadowMaterial\",\r\n ],\r\n [`${keywordMap.clearcoat}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.clearcoatRoughness}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.clearcoatNormal}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.transmission}`]: [\"MeshPhysicalMaterial\"],\r\n [`${keywordMap.thickness}`]: [\"MeshPhysicalMaterial\"],\r\n};\r\n","import * as THREE from \"three\";\r\nimport { CSMPatchMap } from \"../types\";\r\nimport { keywordMap } from \"./keywordMap\";\r\n\r\n// Map of CSM keywords to their substitutions\r\nexport const defaultPatchMap: CSMPatchMap = {\r\n // VERT\r\n \"*\": {\r\n \"#include \":\r\n THREE.ShaderChunk.lights_physical_fragment,\r\n \"#include \": THREE.ShaderChunk.transmission_fragment,\r\n },\r\n [`${keywordMap.normal}`]: {\r\n \"#include \": `\r\n vec3 objectNormal = ${keywordMap.normal};\r\n #ifdef USE_TANGENT\r\n\t vec3 objectTangent = vec3( tangent.xyz );\r\n #endif\r\n `,\r\n },\r\n [`${keywordMap.position}`]: {\r\n \"#include \": `\r\n vec3 transformed = ${keywordMap.position};\r\n `,\r\n },\r\n [`${keywordMap.positionRaw}`]: {\r\n \"#include \": `\r\n vec4 csm_internal_positionUnprojected = ${keywordMap.positionRaw};\r\n mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix;\r\n #ifdef USE_INSTANCING\r\n csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix;\r\n #endif\r\n csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected;\r\n vec3 transformed = csm_internal_positionUnprojected.xyz;\r\n `,\r\n },\r\n [`${keywordMap.pointSize}`]: {\r\n \"gl_PointSize = size;\": `\r\n gl_PointSize = ${keywordMap.pointSize};\r\n `,\r\n },\r\n\r\n // FRAG\r\n\r\n [`${keywordMap.diffuse}`]: {\r\n \"#include \": `\r\n #include \r\n diffuseColor = ${keywordMap.diffuse};\r\n `,\r\n },\r\n [`${keywordMap.fragColor}`]: {\r\n \"#include \": `\r\n #include \r\n gl_FragColor = mix(gl_FragColor, ${keywordMap.fragColor}, ${keywordMap.fragColorInfluence});\r\n `,\r\n },\r\n [`${keywordMap.emissive}`]: {\r\n \"vec3 totalEmissiveRadiance = emissive;\": `\r\n vec3 totalEmissiveRadiance = ${keywordMap.emissive};\r\n `,\r\n },\r\n [`${keywordMap.roughness}`]: {\r\n \"#include \": `\r\n #include \r\n roughnessFactor = ${keywordMap.roughness};\r\n `,\r\n },\r\n [`${keywordMap.metalness}`]: {\r\n \"#include \": `\r\n #include \r\n metalnessFactor = ${keywordMap.metalness};\r\n `,\r\n },\r\n [`${keywordMap.ao}`]: {\r\n \"#include \": `\r\n #include \r\n reflectedLight.indirectDiffuse *= 1. - ${keywordMap.ao};\r\n `,\r\n },\r\n [`${keywordMap.bump}`]: {\r\n \"#include \": `\r\n #include \r\n\r\n vec3 csm_internal_orthogonal = ${keywordMap.bump} - (dot(${keywordMap.bump}, normal) * normal);\r\n vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal;\r\n normal = normalize(normal - csm_internal_projectedbump);\r\n `,\r\n },\r\n [`${keywordMap.depthAlpha}`]: {\r\n \"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\": `\r\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * ${keywordMap.depthAlpha} );\r\n `,\r\n \"gl_FragColor = packDepthToRGBA( fragCoordZ );\": `\r\n if(${keywordMap.depthAlpha} > 0.0) discard;\r\n gl_FragColor = packDepthToRGBA( dist );\r\n `,\r\n \"gl_FragColor = packDepthToRGBA( dist );\": `\r\n if(${keywordMap.depthAlpha} > 0.0) discard;\r\n gl_FragColor = packDepthToRGBA( dist );\r\n `,\r\n },\r\n [`${keywordMap.clearcoat}`]: {\r\n \"material.clearcoat = clearcoat;\": `material.clearcoat = ${keywordMap.clearcoat};`,\r\n },\r\n [`${keywordMap.clearcoatRoughness}`]: {\r\n \"material.clearcoatRoughness = clearcoatRoughness;\": `material.clearcoatRoughness = ${keywordMap.clearcoatRoughness};`,\r\n },\r\n [`${keywordMap.clearcoatNormal}`]: {\r\n \"#include \": `\r\n vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal);\r\n vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal;\r\n vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump);\r\n `,\r\n },\r\n [`${keywordMap.transmission}`]: {\r\n \"material.transmission = transmission;\": `\r\n material.transmission = ${keywordMap.transmission};\r\n `,\r\n },\r\n [`${keywordMap.thickness}`]: {\r\n \"material.thickness = thickness;\": `\r\n material.thickness = ${keywordMap.thickness};\r\n `,\r\n },\r\n [`${keywordMap.iridescence}`]: {\r\n \"material.iridescence = iridescence;\": `\r\n material.iridescence = ${keywordMap.iridescence};\r\n `,\r\n },\r\n};\r\n","import { keywordMap } from \"./keywordMap\";\r\n\r\n/**\r\n * Map of props to their keywords\r\n * this is because Three only injects some defines if certain properties are set in the material options.\r\n *\r\n * For example, \"clearcoat\" must be set for 3js to include the #USE_CLEARCOAT define in the shader.\r\n * and thus for our custom clearcoar variant to work\r\n */\r\nexport const requiredPropsMap = {\r\n clearcoat: [\r\n keywordMap.clearcoat,\r\n keywordMap.clearcoatNormal,\r\n keywordMap.clearcoatRoughness,\r\n ],\r\n transmission: [keywordMap.transmission],\r\n iridescence: [keywordMap.iridescence],\r\n};\r\n","//https://github.com/sindresorhus/sdbm\r\n\r\nexport default function sdbm(string) {\r\n let hash = 0;\r\n\r\n for (let i = 0; i < string.length; i++) {\r\n hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;\r\n }\r\n\r\n // Convert it to an unsigned 32-bit integer.\r\n const h = hash >>> 0;\r\n const str = String(h);\r\n return str;\r\n}\r\n","import { MaterialConstructor } from \"./types\";\r\n\r\n// Hacky, yikes!\r\nexport function isConstructor(\r\n f: T | InstanceType\r\n): f is T {\r\n try {\r\n // @ts-ignore\r\n new f();\r\n } catch (err) {\r\n if ((err as any).message.indexOf(\"is not a constructor\") >= 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\n\r\nexport function deepMergeObjects>(\r\n target: T,\r\n source: T\r\n): T {\r\n for (const key in source) {\r\n // @ts-ignore\r\n if (source[key] instanceof Object)\r\n Object.assign(source[key], deepMergeObjects(target[key], source[key]));\r\n }\r\n\r\n Object.assign(target || {}, source);\r\n return target;\r\n}\r\n\r\n// Remove all comments in a string\r\n// both block and inline comments\r\nexport function stripComments(str: string) {\r\n return str.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, \"\");\r\n}\r\n\r\nexport function stripNewLines(str: string) {\r\n return str.replace(/\\n/g, \"\");\r\n}\r\n\r\nexport function stripSpaces(str: string) {\r\n return str.replace(/\\s/g, \"\");\r\n}\r\n\r\nexport function isEmptyFunction(func: Function) {\r\n const funcName = func.name;\r\n return stripSpaces(stripNewLines(func.toString())) === `${funcName}(){}`;\r\n}\r\n","import * as THREE from \"three\";\r\nimport {\r\n defaultCsmDefinitions,\r\n defaultCsmMainDefinitions,\r\n defaultFragDefinitions,\r\n defaultFragMain,\r\n defaultVertDefinitions,\r\n defaultVertMain,\r\n} from \"./defaults\";\r\nimport { availabilityMap, defaultPatchMap } from \"./maps\";\r\nimport { requiredPropsMap } from \"./maps/requiredPropsMap\";\r\nimport hash from \"./sdbm\";\r\nimport * as TYPES from \"./types\";\r\nimport {\r\n deepMergeObjects,\r\n isConstructor,\r\n isEmptyFunction,\r\n stripComments,\r\n} from \"./utils\";\r\n\r\nexport default class CustomShaderMaterial<\r\n T extends TYPES.MaterialConstructor = typeof THREE.Material\r\n> extends THREE.Material {\r\n uniforms: TYPES.Uniform = {};\r\n vertexShader: string = \"\";\r\n fragmentShader: string = \"\";\r\n\r\n constructor({\r\n baseMaterial,\r\n vertexShader,\r\n fragmentShader,\r\n uniforms,\r\n patchMap,\r\n cacheKey,\r\n ...opts\r\n }: TYPES.CustomShaderMaterialParameters) {\r\n if (!baseMaterial) {\r\n throw new Error(\"CustomShaderMaterial: baseMaterial is required.\");\r\n }\r\n\r\n let base: THREE.Material;\r\n if (isConstructor(baseMaterial)) {\r\n // If base material is a constructor, instantiate it\r\n // if opts is empty, replace it with undefined\r\n const isEmptyOpts = Object.keys(opts).length === 0;\r\n base = new baseMaterial(isEmptyOpts ? undefined : opts);\r\n } else {\r\n // Else, use the already created instance as the base material\r\n // and copy options onto it\r\n base = baseMaterial;\r\n Object.assign(base, opts);\r\n }\r\n\r\n // Blacklist some materials that are not supported\r\n const blackList = [\"ShaderMaterial\", \"RawShaderMaterial\"];\r\n if (blackList.includes(base.type)) {\r\n throw new Error(\r\n `CustomShaderMaterial does not support ${base.type} as a base material.`\r\n );\r\n }\r\n\r\n super();\r\n\r\n // Return a proxy to the base material with CSM types and methods\r\n const extendedBase = base as typeof base & TYPES.CSMProxy;\r\n extendedBase.name = `CustomShaderMaterial<${base.name}>`;\r\n extendedBase.update = this.update.bind(extendedBase);\r\n extendedBase.__csm = { prevOnBeforeCompile: base.onBeforeCompile };\r\n\r\n const prevUniforms = extendedBase.uniforms || {};\r\n const newUniforms = uniforms || {};\r\n const mergedUniforms = { ...prevUniforms, ...newUniforms };\r\n\r\n extendedBase.uniforms = this.uniforms = mergedUniforms;\r\n extendedBase.vertexShader = this.vertexShader = vertexShader || \"\";\r\n extendedBase.fragmentShader = this.fragmentShader = fragmentShader || \"\";\r\n\r\n // Initialize custom shaders\r\n extendedBase.update({\r\n fragmentShader: extendedBase.fragmentShader,\r\n vertexShader: extendedBase.vertexShader,\r\n uniforms: extendedBase.uniforms,\r\n patchMap,\r\n cacheKey,\r\n });\r\n\r\n return extendedBase;\r\n }\r\n\r\n update({\r\n fragmentShader: _fs,\r\n vertexShader: _vs,\r\n uniforms,\r\n cacheKey,\r\n patchMap,\r\n }: Omit, \"baseMaterial\">) {\r\n // Strip comments from shaders, makes it so that commented keywords are not detected\r\n const vertexShader = stripComments(_vs || \"\");\r\n const fragmentShader = stripComments(_fs || \"\");\r\n\r\n // Get typed `this` for the proxy\r\n const self = this as typeof this & TYPES.CSMProxy;\r\n\r\n // Replace the shaders if they are provided\r\n if (uniforms) self.uniforms = uniforms;\r\n if (_vs) self.vertexShader = _vs;\r\n if (_fs) self.fragmentShader = _fs;\r\n\r\n // Some keywords require certain properties to be set for their chunks to be included via #ifdef\r\n // so we must check if the shaders contain these keywords and set the properties accordingly\r\n Object.entries(requiredPropsMap).forEach(([prop, matchKeywords]) => {\r\n for (const keyword in matchKeywords) {\r\n const matchKeyword = matchKeywords[keyword];\r\n if (\r\n (fragmentShader && fragmentShader.includes(matchKeyword)) ||\r\n (vertexShader && vertexShader.includes(matchKeyword))\r\n ) {\r\n // @ts-ignore\r\n if (!self[prop]) {\r\n // @ts-ignore\r\n self[prop] = 1;\r\n }\r\n }\r\n }\r\n });\r\n\r\n // Check it the previous onBeforeCompile exists\r\n const prevOnBeforeCompile = self.__csm.prevOnBeforeCompile;\r\n const doesHavePreviousBeforeCompile = !isEmptyFunction(prevOnBeforeCompile);\r\n\r\n // Helper function to extend the shader\r\n const extendShader = (\r\n prevShader: string,\r\n newShader?: string,\r\n isFrag?: boolean\r\n ) => {\r\n let mainBody: string | undefined;\r\n let beforeMain: string = \"\";\r\n\r\n // Prepare the main body and beforeMain\r\n if (newShader) {\r\n const mainBodyRegex =\r\n /void\\s+main\\s*\\(\\s*\\)[^{]*{((?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{(?:[^{}]+|{[^{}]*})*})*})*})*})/gm;\r\n const mainBodyMatches = newShader.matchAll(mainBodyRegex);\r\n mainBody = mainBodyMatches.next().value?.[1];\r\n if (mainBody) mainBody = mainBody.slice(0, -1);\r\n\r\n const mainIndex = newShader.indexOf(\"void main() {\");\r\n beforeMain = newShader.slice(0, mainIndex);\r\n }\r\n\r\n // Inject\r\n if (doesHavePreviousBeforeCompile) {\r\n prevShader = prevShader.replace(\r\n \"void main() {\",\r\n `\r\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\r\n \r\n ${beforeMain}\r\n \r\n void main() {\r\n `\r\n );\r\n\r\n const lastMainEndIndex = prevShader.lastIndexOf(\"//~CSM_MAIN_END\");\r\n\r\n if (lastMainEndIndex !== -1) {\r\n const toAppend = `\r\n ${mainBody ? `${mainBody}` : \"\"}\r\n //~CSM_MAIN_END\r\n `;\r\n prevShader =\r\n prevShader.slice(0, lastMainEndIndex) +\r\n toAppend +\r\n prevShader.slice(lastMainEndIndex);\r\n }\r\n } else {\r\n const regex = /void\\s*main\\s*\\(\\s*\\)\\s*{/gm;\r\n\r\n prevShader = prevShader.replace(\r\n regex,\r\n `\r\n // THREE-CustomShaderMaterial by Faraz Shaikh: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial\r\n \r\n ${isFrag ? defaultFragDefinitions : defaultVertDefinitions}\r\n ${defaultCsmDefinitions}\r\n \r\n ${beforeMain}\r\n \r\n void main() {\r\n ${defaultCsmMainDefinitions}\r\n ${isFrag ? defaultFragMain : defaultVertMain}\r\n\r\n ${mainBody ? `${mainBody}` : \"\"}\r\n //~CSM_MAIN_END\r\n `\r\n );\r\n }\r\n\r\n return prevShader;\r\n };\r\n\r\n // Override onBeforeCompile\r\n self.onBeforeCompile = (\r\n shader: THREE.WebGLProgramParametersWithUniforms,\r\n renderer: THREE.WebGLRenderer\r\n ) => {\r\n // Apply previous onBeforeCompile\r\n prevOnBeforeCompile?.(shader, renderer);\r\n\r\n const userPatchMap = patchMap || {};\r\n const mergedPatchMap = deepMergeObjects(defaultPatchMap, userPatchMap);\r\n\r\n // Append some defines\r\n const type = self.type;\r\n const typeDefine = type\r\n ? `#define IS_${type.toUpperCase()};\\n`\r\n : `#define IS_UNKNOWN;\\n`;\r\n shader.vertexShader =\r\n typeDefine + \"#define IS_VERTEX\\n\" + shader.vertexShader;\r\n shader.fragmentShader =\r\n typeDefine + \"#define IS_FRAGMENT\\n\" + shader.fragmentShader;\r\n\r\n // Check if the keyword is available in the current material type\r\n for (const keyword in mergedPatchMap) {\r\n const doesIncludeInVert =\r\n keyword === \"*\" || (vertexShader && vertexShader.includes(keyword));\r\n const doesIncludeInFrag =\r\n keyword === \"*\" ||\r\n (fragmentShader && fragmentShader.includes(keyword));\r\n\r\n if (doesIncludeInFrag || doesIncludeInVert) {\r\n const availableIn = availabilityMap[keyword];\r\n\r\n if (\r\n availableIn &&\r\n availableIn !== \"*\" &&\r\n (Array.isArray(availableIn)\r\n ? !availableIn.includes(type)\r\n : availableIn !== type)\r\n ) {\r\n console.error(\r\n `CustomShaderMaterial: ${keyword} is not available in ${type}. Shader cannot compile.`\r\n );\r\n return;\r\n }\r\n\r\n const patchMap = mergedPatchMap[keyword];\r\n\r\n for (const toReplace in patchMap) {\r\n const replaceWith = patchMap[toReplace];\r\n if (typeof replaceWith === \"object\") {\r\n const type = replaceWith.type;\r\n const value = replaceWith.value;\r\n\r\n if (type === \"fs\") {\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n toReplace,\r\n value\r\n );\r\n } else if (type === \"vs\") {\r\n shader.vertexShader = shader.vertexShader.replace(\r\n toReplace,\r\n value\r\n );\r\n }\r\n } else if (replaceWith) {\r\n shader.vertexShader = shader.vertexShader.replace(\r\n toReplace,\r\n replaceWith\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n toReplace,\r\n replaceWith\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Extend the shaders\r\n shader.vertexShader = extendShader(\r\n shader.vertexShader,\r\n vertexShader,\r\n false\r\n );\r\n\r\n shader.fragmentShader = extendShader(\r\n shader.fragmentShader,\r\n fragmentShader,\r\n true\r\n );\r\n\r\n if (uniforms) {\r\n shader.uniforms = { ...shader.uniforms, ...self.uniforms };\r\n }\r\n\r\n self.uniforms = shader.uniforms;\r\n };\r\n\r\n const prevCacheKey = self.customProgramCacheKey;\r\n\r\n self.customProgramCacheKey = () => {\r\n return (\r\n (cacheKey?.() || hash((vertexShader || \"\") + (fragmentShader || \"\"))) +\r\n prevCacheKey?.call(self)\r\n );\r\n };\r\n\r\n self.needsUpdate = true;\r\n }\r\n}\r\n\r\nexport {\r\n type CSMPatchMap,\r\n type CSMProxy,\r\n type CustomShaderMaterialParameters,\r\n type MaterialConstructor,\r\n} from \"./types\";\r\n"],"names":["defaultCsmDefinitions","defaultCsmMainDefinitions","defaultVertDefinitions","defaultVertMain","defaultFragDefinitions","defaultFragMain","keywordMap","availabilityMap","defaultPatchMap","THREE","requiredPropsMap","sdbm","string","hash","i","h","isConstructor","f","err","deepMergeObjects","target","source","key","stripComments","str","stripNewLines","stripSpaces","isEmptyFunction","func","funcName","CustomShaderMaterial","baseMaterial","vertexShader","fragmentShader","uniforms","patchMap","cacheKey","opts","base","isEmptyOpts","extendedBase","mergedUniforms","_fs","_vs","self","prop","matchKeywords","keyword","matchKeyword","prevOnBeforeCompile","doesHavePreviousBeforeCompile","extendShader","prevShader","newShader","isFrag","mainBody","beforeMain","mainBodyRegex","_a","mainIndex","lastMainEndIndex","toAppend","regex","shader","renderer","mergedPatchMap","type","typeDefine","doesIncludeInVert","availableIn","toReplace","replaceWith","value","prevCacheKey"],"mappings":";AAAa,MAAAA;AAAA;AAAA,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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b/index.d.ts @@ -0,0 +1,10 @@ +import * as THREE from "three"; +import * as TYPES from "./types"; +export default class CustomShaderMaterial extends THREE.Material { + uniforms: TYPES.Uniform; + vertexShader: string; + fragmentShader: string; + constructor({ baseMaterial, vertexShader, fragmentShader, uniforms, patchMap, cacheKey, ...opts }: TYPES.CustomShaderMaterialParameters); + update({ fragmentShader: _fs, vertexShader: _vs, uniforms, cacheKey, patchMap, }: Omit, "baseMaterial">): void; +} +export { type CSMPatchMap, type CSMProxy, type CustomShaderMaterialParameters, type MaterialConstructor, } from './types'; diff --git a/maps/availabilityMap.d.ts b/maps/availabilityMap.d.ts new file mode 100644 index 0000000..c07a7e2 --- /dev/null +++ b/maps/availabilityMap.d.ts @@ -0,0 +1,3 @@ +export declare const availabilityMap: { + [x: string]: string | string[]; +}; diff --git a/maps/index.d.ts b/maps/index.d.ts new file mode 100644 index 0000000..d7febab --- /dev/null +++ b/maps/index.d.ts @@ -0,0 +1,3 @@ +export * from './availabilityMap'; +export * from './keywordMap'; +export * from './patchMap'; diff --git a/maps/keywordMap.d.ts b/maps/keywordMap.d.ts new file mode 100644 index 0000000..2b71ec8 --- /dev/null +++ b/maps/keywordMap.d.ts @@ -0,0 +1,21 @@ +export declare const keywordMap: { + diffuse: string; + normal: string; + roughness: string; + metalness: string; + emissive: string; + ao: string; + bump: string; + clearcoat: string; + clearcoatRoughness: string; + clearcoatNormal: string; + transmission: string; + thickness: string; + iridescence: string; + pointSize: string; + fragColor: string; + depthAlpha: string; + fragColorInfluence: string; + position: string; + positionRaw: string; +}; diff --git a/maps/patchMap.d.ts b/maps/patchMap.d.ts new file mode 100644 index 0000000..bfc4572 --- /dev/null +++ b/maps/patchMap.d.ts @@ -0,0 +1,3 @@ +import { CSMPatchMap } from '../types'; + +export declare const defaultPatchMap: CSMPatchMap; diff --git a/maps/requiredPropsMap.d.ts b/maps/requiredPropsMap.d.ts new file mode 100644 index 0000000..fe788ec --- /dev/null +++ b/maps/requiredPropsMap.d.ts @@ -0,0 +1,12 @@ +/** + * Map of props to their keywords + * this is because Three only injects some defines if certain properties are set in the material options. + * + * For example, "clearcoat" must be set for 3js to include the #USE_CLEARCOAT define in the shader. + * and thus for our custom clearcoar variant to work + */ +export declare const requiredPropsMap: { + clearcoat: string[]; + transmission: string[]; + iridescence: string[]; +}; diff --git a/sdbm.d.ts b/sdbm.d.ts new file mode 100644 index 0000000..d86cd73 --- /dev/null +++ b/sdbm.d.ts @@ -0,0 +1 @@ +export default function sdbm(string: any): string; diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000..3a7ad73 --- /dev/null +++ b/types.d.ts @@ -0,0 +1,36 @@ +import * as THREE from "three"; +export interface IUniform { + value: TValue; +} +export type Uniform = { + [key: string]: IUniform; +}; +export type MaterialConstructor = new (...opts: any[]) => THREE.Material; +type MaterialParams = ConstructorParameters[0]; +export type CSMPatchMap = { + [keyword: string]: { + [toReplace: string]: string | { + value: string; + type: "fs" | "vs"; + }; + }; +}; +export type CustomShaderMaterialBaseParameters = { + baseMaterial: T | InstanceType; + vertexShader?: string; + fragmentShader?: string; + uniforms?: Uniform; + patchMap?: CSMPatchMap; + cacheKey?: () => string; +}; +export type CustomShaderMaterialParameters = CustomShaderMaterialBaseParameters & (MaterialParams extends undefined ? any : MaterialParams); +export type CSMProxy = InstanceType & { + vertexShader: string; + fragmentShader: string; + uniforms: Uniform; + update: (opts: Omit, "baseMaterial">) => void; + __csm: { + prevOnBeforeCompile: THREE.Material["onBeforeCompile"]; + }; +}; +export {}; diff --git a/utils.d.ts b/utils.d.ts new file mode 100644 index 0000000..6b013d6 --- /dev/null +++ b/utils.d.ts @@ -0,0 +1,8 @@ +import { MaterialConstructor } from './types'; + +export declare function isConstructor(f: T | InstanceType): f is T; +export declare function deepMergeObjects>(target: T, source: T): T; +export declare function stripComments(str: string): string; +export declare function stripNewLines(str: string): string; +export declare function stripSpaces(str: string): string; +export declare function isEmptyFunction(func: Function): boolean;